如何在PHP中得到多维关联数组子多维关联数组?

问题描述 投票:-2回答:1

我有一个多维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')
php arrays multidimensional-array associative
1个回答
0
投票

我找到了这个问题的解决方案。

$result = array_combine(array_column(array_column($room_recordings,"meetingId"),0), array_column(array_column($room_recordings,"playback"),0));
© www.soinside.com 2019 - 2024. All rights reserved.