Tuesday, March 26, 2013

PHP Function to stripslashes from an array

Hello friends,

Today I was working and was using stripslashes a lot from all the variables. So I thought about creating a function which can stripslashes from the whole array, so I created this function and want to share it with you guys as well. So I am posting this code to stripslashes from an array.

We all know that there is a function to stripslashes from an string in PHP but the function which I am posting in Developer's Blog right now will stripslashes from an array.

function stripSlashesArray($array)
{
    foreach($array as $key => $val)
    {
        if (is_array($val))
        {
             $array[$key] = stripSlashesArray($val);
        }
        else
        {
             $array[$key] = stripslashes($val);
        }
    }
    return $array;
}


I hope this will help you and you will like it.

Don't forget to leave your comments.

Thank you
Ravinder

No comments:

Post a Comment