note 69020 added to function.addslashes
| From: | joechrz at gmail dot com | Date: | Sun, 20 Aug 2006 00:36:28 +0000 |
| Subject: | note 69020 added to function.addslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116074@lists.php.net to get a copy of this message | ||
Here's an example of a function that prevents double-quoting, I'm surprised noone has put
something like this up yet... (also works on arrays)
<?php
function escape_quotes($receive) {
if (!is_array($receive))
$thearray = array($receive);
else
$thearray = $receive;
foreach (array_keys($thearray) as $string) {
$thearray[$string] = addslashes($thearray[$string]);
$thearray[$string] = preg_replace("/[\\/]+/","/",$thearray[$string]);
}
if (!is_array($receive))
return $thearray[0];
else
return $thearray;
}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 68.61.148.93
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.addslashes.php
Edit -- https://master.php.net/note/edit/69020
Del: integrated -- https://master.php.net/note/delete/69020/integrated
Del: useless -- https://master.php.net/note/delete/69020/useless
Del: bad code -- https://master.php.net/note/delete/69020/bad+code
Del: spam -- https://master.php.net/note/delete/69020/spam
Del: non-english -- https://master.php.net/note/delete/69020/non-english
Del: in docs -- https://master.php.net/note/delete/69020/in+docs
Del: other reasons-- https://master.php.net/note/delete/69020
Reject -- https://master.php.net/note/reject/69020
Search -- https://master.php.net/manage/user-notes.php