0

php array_search()

I need to find some Values inside an existing Array. Therefore i found the method array_search wich gets filled like this: array_search(value your searching for, $array you want to search in) so... i have to check for more than 30 Values wich is why i made an Array for it. So what i want to do is: array_search($array1, $array2) sadly its not working for me. Is there a trick on how to make it run or a different way for it? Thanks to everyone helping!

24th Dec 2019, 8:42 PM
Jonas Prell
Jonas Prell - avatar
2 Answers
+ 1
you can do something like this : search $arr0 values in $arr1 <?php $arr0 = array("a","b","c"); $arr1 = array("x","y","b"); foreach($arr0 as $srch){ echo array_search($srch, $arr1); } ?> it prints the indexes if found, you can change it to do something else.
24th Dec 2019, 10:26 PM
Bahha┣
Bahha┣ - avatar
0
thanks!
25th Dec 2019, 1:10 AM
Jonas Prell
Jonas Prell - avatar