PHP: get keys of independent arrays

后端 未结 2 1268
醉酒成梦
醉酒成梦 2020-12-19 20:53

I have two arrays.

Example of the first array:

$arrayOne = array
(
    \'fruit\' => array(
        \'apples\' => array(),
        \'oranges\' => array(),
         


        
2条回答
  •  伪装坚强ぢ
    2020-12-19 21:26

    Check out array_keys from both arrays and then map the positions. Like array_keys for your arrays will give you -

    $arrayKeyOne = array('fruit', 'vegetables', 'meat', 'other');
    $arrayKeyTwo = array('frewt', 'vetchteblz', 'meat', 'mother');
    

    Then a $arrayKeyTwo[array_search($one, $arrayKeyOne)] shuld give you what you want. Let know if this helps.

提交回复
热议问题