How to: Looping Through Associative Arrays
Posted: Sun Dec 05, 2004 11:01 am
Hi everyone,
I haven't had a chance to test this yet but from what I see it should work. I just wanted to get some comments on this to see if anyone notices a reason why it wouldn't work, or knows of a better way to do it.
I haven't had a chance to test this yet but from what I see it should work. I just wanted to get some comments on this to see if anyone notices a reason why it wouldn't work, or knows of a better way to do it.
Code: Select all
<?php
/**
* [agtlewis@yahoo.com]
* Remove Magic Quotes from a variable or from each
* element in an array, if they are turned on.
*/
function RemoveMagicQuotes($DataString)
{
reset($DataString);
if (!get_magic_quotes_gpc())
{
current($DataString) = trim(current($DataString));
while(next($DataString))
{
current($DataString) = trim(current($DataString));
}
}
else
{
current($DataString) = trim(stripslashes(current($DataString)));
while(next($DataString))
{
current($DataString) = trim(stripslashes(current($DataString)));
}
}
return $DataString;
}
?>