note 18881 added to function.preg-match

From: Date: Fri, 08 Feb 2002 10:12:05 +0000
Subject: note 18881 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-26377@lists.php.net to get a copy of this message
Quick Note to ease Perl to PHP Translation. preg_match that return an array.... that can be directly sent into a list($r1, $r2, $r3) function preg_match_array( $pattern, $stringtoregex ) { // To Ease Translation from Perl to PHP // In Perl We Use Often ( $a, $b, $c) = ( $stringtoregex ~= // /^(...) (...) (...)$/ ); // Translate this into PHP Code like this // list( $a, $b, $c) = preg_grep_array( // "/^(...) (...) (...)$/", // $stringtoregex); $retarray=array(); preg_match( $pattern, $stringtoregex, $retarray); // Destroy index zero which is the whole string unset( $retarray[0]); return $retarray; } -- http://www.php.net/manual/en/function.preg-match.php http://master.php.net/manage/user-notes.php?action=edit+18881 http://master.php.net/manage/user-notes.php?action=delete+18881 http://master.php.net/manage/user-notes.php?action=reject+18881

« previous php.notes (#26377) next »