note 76665 deleted from function.preg-replace by cmb
| From: | cmb@php.net | Date: | Sun, 22 Sep 2019 07:58:55 +0000 |
| Subject: | note 76665 deleted from function.preg-replace by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212299@lists.php.net to get a copy of this message | ||
Note Submitter: lehongviet at gmail dot com
----
I got problem echoing text that contains double-quotes into a text field. As it confuses value
option. I use this function below to match and replace each pair of them by smart quotes. The last
one will be replaced by a hyphen(-).
It works for me.
<?php
function smart_quotes($text) {
$pattern = '/"((.)*?)"/i';
$text = preg_replace($pattern,"â\\1â",stripslashes($text));
$text = str_replace("\"","-",$text);
$text = addslashes($text);
return $text;
}
?>