Last active
January 16, 2024 17:57
-
-
Save Aabill/ad6bc35eb8121e877ec9214fc4000fc4 to your computer and use it in GitHub Desktop.
Filtering Array with in_array() function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$products = [ | |
["code" => 'btk', "name" => 'Butik'], | |
["code" => 'umt', "name" => 'Urmot'], | |
["code" => 'klo', "name" => 'Kalbo'], | |
]; | |
$codes = ["umt","btk"]; | |
$filtered = array_filter($products, function($p) use($codes) { | |
return in_array($p["code"], $codes); | |
}); | |
var_dump($filtered); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment