doushi7314 2011-06-04 04:32
浏览 337
已采纳

PHP将数组拆分为两个数组 - 键数组和值数组

Is there an easy way to split an array into two arrays, one consisting of all the keys and the other consisting of all the values? This would be a reverse to the action of array_combine. Is there an inbuilt function for doing such a task? Let's use an example array:

$array = array('Tiger' => 'Forest', 'Hippo' => 'River', 'Bird' => 'Sky');

Is there a function that will split the above array into:

$array_keys = array('Tiger', 'Hippo', 'Bird');
$array_values = array('Forest', 'River', 'Sky');
  • 写回答

6条回答 默认 最新

  • dongzhi9906 2011-06-04 04:34
    关注

    There are two functions called array_keys and array_values:

    $array_keys = array_keys($array);
    $array_values = array_values($array);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?