note 130000 added to function.preg-grep
| From: | laurent@d-nada.com | Date: | Wed, 29 Jan 2025 09:57:44 +0000 |
| Subject: | note 130000 added to function.preg-grep | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221818@lists.php.net to get a copy of this message | ||
If you want to filter a string by searching for what does not match what is specified in your
regular expression, you can use this :
<?php
$array = [ "GNU/Linux", "MacOS", "Window" ];
var_dump( array_diff($array, preg_grep("/Wind/", $array)) );
?>
this results in:
array (2) [ "GNU/Linux", "MacOS" ]
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 2a01:e0a:4a0:ddf0:78de:cfc9:4bcb:4aa1)
----
Manual Page -- https://php.net/manual/en/function.preg-grep.php
Edit -- https://main.php.net/note/edit/130000
Del: integrated -- https://main.php.net/note/delete/130000/integrated
Del: useless -- https://main.php.net/note/delete/130000/useless
Del: bad code -- https://main.php.net/note/delete/130000/bad+code
Del: spam -- https://main.php.net/note/delete/130000/spam
Del: non-english -- https://main.php.net/note/delete/130000/non-english
Del: in docs -- https://main.php.net/note/delete/130000/in+docs
Del: other reasons-- https://main.php.net/note/delete/130000
Reject -- https://main.php.net/note/reject/130000
Search -- https://main.php.net/manage/user-notes.php