How to use array_search in PHP 5.6

Multi tool use


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
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.
array_search
searches a single value. Either search for each value of second array in a loop, or usearray_intersect
.– u_mulder
1 min ago