Zend - The PHP Company




Security

Add Code


Reverse the effects of magic_quotes  

Type: code fragment
Added by: secondv
Entered: 20/08/2006
Last modified: 09/12/2005
Rating: - (fewer than 3 votes)
Views: 2541
Simple function to remove slashes from an entire array.


<?php

function reverse_magic_quotes(&$array)
{
    if (
is_array($array))
    {
        foreach (
$array AS $key => $val)
        {
            if (
is_string($val))
            {
                
$array["$key"] = stripslashes($val);
            }
            else if (
is_array($val))
            {
                
reverse_magic_quotes($array["$key"]);
            }
        }
    }
}

?>


Usage Example


//reverse_magic_quotes($_REQUEST); // Seems to be needed on PHP5
reverse_magic_quotes($_POST);
reverse_magic_quotes($_GET);
reverse_magic_quotes($_COOKIE);


Rate This Script





Search



This Category All Categories