note 89933 added to function.preg-grep

From: Date: Sun, 29 Mar 2009 23:29:12 +0000
Subject: note 89933 added to function.preg-grep
Groups: php.notes 
Request: Send a blank email to php-notes+get-152590@lists.php.net to get a copy of this message
@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 ) */ ?> ---- Server IP: 208.69.120.35 Probable Submitter: 98.223.243.137 ---- Manual Page -- http://www.php.net/manual/en/function.preg-grep.php Edit -- https://master.php.net/note/edit/89933 Del: integrated -- https://master.php.net/note/delete/89933/integrated Del: useless -- https://master.php.net/note/delete/89933/useless Del: bad code -- https://master.php.net/note/delete/89933/bad+code Del: spam -- https://master.php.net/note/delete/89933/spam Del: non-english -- https://master.php.net/note/delete/89933/non-english Del: in docs -- https://master.php.net/note/delete/89933/in+docs Del: other reasons-- https://master.php.net/note/delete/89933 Reject -- https://master.php.net/note/reject/89933 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152590) next »