note 86835 deleted from function.sprintf by cmb

From: Date: Sun, 14 Jul 2019 11:16:03 +0000
Subject: note 86835 deleted from function.sprintf by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211557@lists.php.net to get a copy of this message
Note Submitter: MelTraX ---- <?php // parses a string meant for printf and returns an array of found parameters (or NULL if it contains syntax errors) function parsePrintfParameters($string) { $valid = '/^(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])/'; $originalString = $string; $result = array(); while(strlen($string)) { if(!$string = preg_replace('/^[^%]*/', '', $string)) break; if(preg_match($valid, $string, $matches)) { $result[] = $matches[0]; $string = substr($string, strlen($matches[0])); } else { error(sprintf('"%s" has an error near "%s".', $originalString, $string)); return NULL; } } return $result; } ?>

« previous php.notes (#211557) next »