note 92524 added to function.stripslashes
| From: | JacobRas dot nl at osu1 dot php dot net | Date: | Tue, 28 Jul 2009 12:41:48 +0000 |
| Subject: | note 92524 added to function.stripslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158815@lists.php.net to get a copy of this message | ||
Hi,
Here's an function that strips not only \', but also \\' and \\\' and so on
(depending on $times). $text = the text that needs to be stripped, $times = how much backslashes
should be stripped.
<?php
function stripslashes_deep ($text, $times) {
$i = 0;
// loop will execute $times times.
while (strstr($text, '\\') && $i != $times) {
$text= stripslashes($text);
$i++;
}
return $text;
}
?>
Example: $text = \\'quote\\' . <?php stripslashes_deep($text, 2); ?> will return
'quote'.
Note: <?php stripslashes_deep($text, 3); ?> will also return 'quote'.
----
Server IP: 91.199.167.18
Probable Submitter: 94.212.241.61
----
Manual Page -- http://www.php.net/manual/en/function.stripslashes.php
Edit -- https://master.php.net/note/edit/92524
Del: integrated -- https://master.php.net/note/delete/92524/integrated
Del: useless -- https://master.php.net/note/delete/92524/useless
Del: bad code -- https://master.php.net/note/delete/92524/bad+code
Del: spam -- https://master.php.net/note/delete/92524/spam
Del: non-english -- https://master.php.net/note/delete/92524/non-english
Del: in docs -- https://master.php.net/note/delete/92524/in+docs
Del: other reasons-- https://master.php.net/note/delete/92524
Reject -- https://master.php.net/note/reject/92524
Search -- https://master.php.net/manage/user-notes.php