note 23758 added to function.preg-grep
| From: | zac at slac dot stanford dot edu | Date: | Fri, 26 Jul 2002 23:02:05 +0000 |
| Subject: | note 23758 added to function.preg-grep | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-33618@lists.php.net to get a copy of this message | ||
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
)
--
http://www.php.net/manual/en/function.preg-grep.php
http://master.php.net/manage/user-notes.php?action=edit+23758
http://master.php.net/manage/user-notes.php?action=delete+23758
http://master.php.net/manage/user-notes.php?action=reject+23758