note 87570 deleted from function.preg-match by cmb

From: Date: Sun, 13 Oct 2019 07:57:59 +0000
Subject: note 87570 deleted from function.preg-match by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212622@lists.php.net to get a copy of this message
Note Submitter: Alex Zinchenko ---- 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.

« previous php.notes (#212622) next »