note 96883 added to function.preg-replace-callback

From: Date: Sun, 21 Mar 2010 08:05:49 +0000
Subject: note 96883 added to function.preg-replace-callback
Groups: php.notes 
Request: Send a blank email to php-notes+get-167259@lists.php.net to get a copy of this message
Decode Hexa to Strings =) <?php class PhpHex2Str { private $strings; private function x_hex2str($hex) { $hex = substr($hex[0], 1); $str = ''; for($i=0;$i < strlen($hex);$i+=2) { $str.=chr(hexdec(substr($hex,$i,2))); } return $str; } public function decode($strings = null) { $this->strings = (string) $strings; return preg_replace_callback('#\%[a-zA-Z0-9]{2}#', 'x_hex2str', $this->strings); } } // Example $strings = 'a %20 b%0A h %27 h %23'; $obj = new PhpHex2Str; $strings = $obj->decode($strings); var_dump($strings); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 92.129.227.50 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace-callback.php Edit -- https://master.php.net/note/edit/96883 Del: integrated -- https://master.php.net/note/delete/96883/integrated Del: useless -- https://master.php.net/note/delete/96883/useless Del: bad code -- https://master.php.net/note/delete/96883/bad+code Del: spam -- https://master.php.net/note/delete/96883/spam Del: non-english -- https://master.php.net/note/delete/96883/non-english Del: in docs -- https://master.php.net/note/delete/96883/in+docs Del: other reasons-- https://master.php.net/note/delete/96883 Reject -- https://master.php.net/note/reject/96883 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167259) next »