note 87570 added to function.preg-match
| From: | AlexZinchenko at osu1 dot php dot net | Date: | Thu, 11 Dec 2008 02:15:26 +0000 |
| Subject: | note 87570 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148012@lists.php.net to get a copy of this message | ||
If you need to check whether string is a serialized representation of variable(sic!) you can use
this :
<?php
$string = "a:0:{}";
if(preg_match("/(a|O|s|b)\x3a[0-9]*?
((\x3a((\x7b?(.+)\x7d)|(\x22(.+)\x22\x3b)))|(\x3b))/", $string))
{
echo "Serialized.";
}
else
{
echo "Not serialized.";
}
?>
But don't forget, string in serialized representation could be VERY big,
so match work can be slow, even with fast preg_* functions.
----
Server IP: 195.54.192.44
Probable Submitter: 127.0.0.1
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/87570
Del: integrated -- https://master.php.net/note/delete/87570/integrated
Del: useless -- https://master.php.net/note/delete/87570/useless
Del: bad code -- https://master.php.net/note/delete/87570/bad+code
Del: spam -- https://master.php.net/note/delete/87570/spam
Del: non-english -- https://master.php.net/note/delete/87570/non-english
Del: in docs -- https://master.php.net/note/delete/87570/in+docs
Del: other reasons-- https://master.php.net/note/delete/87570
Reject -- https://master.php.net/note/reject/87570
Search -- https://master.php.net/manage/user-notes.php