Friday, March 29, 2013

PHP Function to addslashes to an array

Hello friends,

Few days before I posted the function which stripslashes from an array. Today I thought about creating a function which addslashes to an array. so I created this function and want to share it with you guys as well. So I am posting this code to addslashes to an array.

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


function addSlashesArray($array
{
    foreach ($array as $key => $val) 
    {
        if (is_array($val))
        {
            $array[$key] = addSlashesArray($val);
        }
        else
        {
            $array[$key] = addslashes($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