mardi 28 mars 2017

check if an multidimensional array's every element can be finded in another multidimensional array

For example,I want to check if every element in "search_this" array can be finded in "all" array (it means the all array has the same value element).

  $search_this = Array
(
(0) => Array
    (
        (id) => '1',
        (name) => 'a'
    ),

(1) => Array
    (
        (id) => '2',
        (name) => 'b'
    ),

(2) => Array
    (
        (id) => '3',
        (name) => 'c'
    )
);

$all = Array
(
(0) => Array
    (
        (id) => '1',
        (name) => 'a'
    ),

(1) => Array
    (
        (id) => '2',
        (name) => 'd'
    ),

(2) => Array
    (
        (id) => '4',
        (name) => 'c'
    )
);

like this ↑ , only one element can be find in "all" array ,not all. thus the result is false.

is there any function in php which can do this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2nfasUA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire