note 104965 added to function.preg-replace
| From: | sreekanth at outsource-online dot net | Date: | Tue, 19 Jul 2011 08:29:27 +0000 |
| Subject: | note 104965 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181686@lists.php.net to get a copy of this message | ||
if your intention to code and decode mod_rewrite urls and handle it with php and mysql ,this should
work
to convert to url
$url = preg_replace('/[^A-Za-z0-9_-]+/', '-', $string);
And to check in mysql with the url value,use the same expression discounting '-'.
first replace the url value with php using preg_replace and use with mysql REGEXP
$sql = "select * from table where fieldname_to_check REGEXP
'".preg_replace("/-+/",'[^A-Za-z0-9_]+',$url)."'"
----
Server IP: 69.147.83.197
Probable Submitter: 122.172.114.126
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/104965
Del: integrated -- https://master.php.net/note/delete/104965/integrated
Del: useless -- https://master.php.net/note/delete/104965/useless
Del: bad code -- https://master.php.net/note/delete/104965/bad+code
Del: spam -- https://master.php.net/note/delete/104965/spam
Del: non-english -- https://master.php.net/note/delete/104965/non-english
Del: in docs -- https://master.php.net/note/delete/104965/in+docs
Del: other reasons-- https://master.php.net/note/delete/104965
Reject -- https://master.php.net/note/reject/104965
Search -- https://master.php.net/manage/user-notes.php