如何在PHP中将多维关联数组转换为子多维关联数组?

时间:2020-06-16 18:13:50

标签: php arrays multidimensional-array associative

我有一个多维PHP数组,如何获得一个多维关联数组,其中键将是meetingId['0']的值,而值将是playback['0']的值?

Array(
    [returncode] => Array([0] => SUCCESS)
    [message] => Array()
    [0] => Array(
        [meetingId] => Array([0] =>3049)
        [name] => Array([0] => Measurement)
        [playback] => Array([0] => mid2020)
    )
    [1] => Array(
        [meetingId] => Array([0] => 3048)
        [name] => Array([0] => Measurement)
        [playback] => Array([0] => mid2019)
    )
    [2] => Array(
        [meetingId] => Array([0] => 3047)
        [name] => Array([0] => Measurement)
        [playback] => Array([0] => mid2018)
    )
)

结果将是:

array('3049'=>'mid2020','3048'=>'mid2019','3047'=>'mid2018')

1 个答案:

答案 0 :(得分:0)

我找到了解决此问题的方法,

$result = array_combine(array_column(array_column($room_recordings,"meetingId"),0), array_column(array_column($room_recordings,"playback"),0));