PDA

View Full Version : sanitizing array values


sabret00the
06-24-2005, 07:13 PM
// sanitizing array values
foreach($getpiece AS $key => $value)
{
if (!is_numeric($value))
{
if ($key == "pagetext")
{
$getpiece['$key'] = stripslashes(nl2br($getpiece[pagetext]));
}
else
{
$getpiece['$key'] = stripslashes($getpiece['$value']);
}
}
else
{
$getpiece['$key'] = $getpiece['$value'];
}
}

what am i doing wrong?

tamarian
06-24-2005, 07:26 PM
$array['$index'] makes the index a lieteral string of '$index', isntead of the actual index variable. So dropping the single quotes will get you acces to the real array index.

sabret00the
06-24-2005, 07:51 PM
yay, that sorted it perfectly, thank you!

tamarian
06-24-2005, 07:54 PM
Glad it helped. Looks like you have an interesting hack going there :)