note 23758 deleted from function.preg-grep by didou

From: Date: Fri, 02 Feb 2007 20:23:03 +0000
Subject: note 23758 deleted from function.preg-grep by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-122577@lists.php.net to get a copy of this message
Note Submitter: zac at slac dot stanford dot edu ---- preg_grep takes a third argument (PREG_GREP_INVERT) which negates the pattern matching behaviour, just like the "-v" flag to the grep command. EXAMPLE: $food = array('apple', 'banana', 'squid', 'pear'); $fruits = preg_grep("/squid/", $food, PREG_GREP_INVERT); echo "Food "; print_r($food); echo "Fruit "; print_r($fruits); RESULTS IN: Food Array ( [0] => apple [1] => banana [2] => squid [3] => pear ) Fruit Array ( [0] => apple [1] => banana [3] => pear )

« previous php.notes (#122577) next »