How to use array_search in PHP 5.6

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How to use array_search in PHP 5.6



I create a array with some values. For example:


array(6) {
[0]=> string(1) "S"
[1]=> string(1) "M"
[2]=> string(2) "XL"
[3]=> string(1) "S"
[4]=> string(1) "M"
[5]=> string(2) "XL"
}



This array is assign to variable $psoft. The second array with values:


string(1) "S" string(1) "M" string(1) "L" string(2) "XL"



And my code:


$klucz = array_search($attrs, $psoft);



Always get bool(false) from $klucz and I don't know why. Thanks for help.





array_search searches a single value. Either search for each value of second array in a loop, or use array_intersect.
– u_mulder
1 min ago




array_search


array_intersect





possible duplicate of array-containers-all-values-from-array
– Webber
1 min ago







Because the 3 part array is not in the string array. You are searching an array in an array.
– kry
27 secs ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Ujr,hYEp HO6LF pwm
J2baeN9jS2Dr o

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results