note 89933 deleted from function.preg-grep by thiago

From: Date: Mon, 30 Mar 2009 12:33:33 +0000
Subject: note 89933 deleted from function.preg-grep by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152614@lists.php.net to get a copy of this message
Note Submitter: Jason ---- @brian at cristina dot org Heh, I only saw your suggestion after I made this to get the inverse of preg_grep. <?php function preg_rgrep($regexp,$array) { if ($regexp == '' || !is_array($array)) { return 0; } return array_diff_assoc($array,preg_grep($regexp,$array)); } /* // $array Array ( [0] => a [1] => abc [2] => cba [3] => avf [4] => gfd [5] => thds [6] => aaa [7] => treh ) // preg_grep('/^a/',$array) Array ( [0] => a [1] => abc [3] => avf [6] => aaa ) // preg_rgrep('/^a/',$array) Array ( [2] => cba [4] => gfd [5] => thds [7] => treh ) */ ?>

« previous php.notes (#152614) next »