note 111426 added to function.stripslashes
| From: | YousefIsmaeilCliprz | Date: | Tue, 19 Feb 2013 07:41:39 +0000 |
| Subject: | note 111426 added to function.stripslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193679@lists.php.net to get a copy of this message | ||
If you want to use stripslashes(); function for a string or array you can create a user function
as in example:
<?php
if (!function_exists('strip_slashes'))
{
/**
* Un-quotes a quoted string.
*
* @param (mixed) $str - The input string.
* @author Yousef Ismaeil Cliprz
*/
function strip_slashes($str)
{
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = strip_slashes($val);
}
}
else
{
$str = stripslashes($str);
}
return $str;
}
}
$arr =
array('Yousef\\\'s','\"PHP.net\"','user\\\'s');
echo 'With strip_slashes() function:<br />';
print_r(strip_slashes($arr));
echo '<br />';
echo 'Without strip_slashes() function:<br />';
print_r($arr);
/** You will get
With strip_slashes() function:
Array ( [0] => Yousef's [1] => "PHP.net" [2] => user's )
Without strip_slashes() function:
Array ( [0] => Yousef\'s [1] => \"PHP.net\" [2] => user\'s )
*/
?>
----
Server IP: 69.147.83.199
Probable Submitter: 31.214.51.92
----
Manual Page -- http://php.net/manual/en/function.stripslashes.php
Edit -- https://master.php.net/note/edit/111426
Del: integrated -- https://master.php.net/note/delete/111426/integrated
Del: useless -- https://master.php.net/note/delete/111426/useless
Del: bad code -- https://master.php.net/note/delete/111426/bad+code
Del: spam -- https://master.php.net/note/delete/111426/spam
Del: non-english -- https://master.php.net/note/delete/111426/non-english
Del: in docs -- https://master.php.net/note/delete/111426/in+docs
Del: other reasons-- https://master.php.net/note/delete/111426
Reject -- https://master.php.net/note/reject/111426
Search -- https://master.php.net/manage/user-notes.php