I have the following php arrays
First array (
[0] => Array (
[0] => "you're so beautiful"
[1] => "you could be a part time model" )
[1] => Array (
[0] => "you're so beautiful"
[1] => "you could be an air hostess in the 60's" )
)
Second array (
[0] => Array (
[0] => "you're so beautiful"
[1] => "you could be a waitress" )
[1] => Array (
[0] => "you're so beautiful"
[1] => "you could be an air hostess in the 60's" )
)
What I want to do is search through the first array (and inside each one of the arrays) and check if the second field [1] is equal to another sentence inside another array. So basically:
foreach($first_array as $value){
array_filter($second_array,function($second_array){
return $second_array[1] = $value[1];
}
What I want is:
Desired array (
[0] => Array (
[0] => "you're so beautiful"
[1] => "you could be an air hostess in the 60's" )
)
because it's the only array where [1] is the common member, and so all of the array is filtered. The problem is return $second_array[1] = $value[1];. $value is not in the scope of the function, and $value depends of the out-of-scope foreach. Also, I'd like to know how I could filter all of the array as described. Thank you very much!