我有两个数组,我需要找出两者之间的差异并将它们显示在无序列表中。
我可以循环遍历主数组以进行单个匹配,但我不知道如何遍历主列表以获取多个键值并有效地执行此操作。
下面是每个数组的关键值的摘录:
要搜索的主阵列
foreach ( $levels as $level ) {
$output .= '<li>' . $level['name'] . '</li>';
包含可能匹配的数组
foreach ( $login_member_levels as $level ) {
$output .= '<li>' . $level_array[]=$level->level . '</li>';
为多维问题添加了信息...
这是我需要比较的两个多维数组,但子数组不匹配:
我需要在第一个数组 [levels][level_id] 和 [levels][level][id] 中进行比较
Array
(
[success] => 1
[member] => Array
(
[0] => Array
(
[ID] => 2
[UserInfo] => Array
(
[ID] => 2
[caps] => Array
(
[administrator] => 1
)
)
[Sequential] =>
[Levels] => Array
(
[1347037874] => stdClass Object
(
[Level_ID] => 1347037874
[Name] => HFM-Cardiac Resistance Training Program
[Cancelled] =>
)
[1347037875] => stdClass Object
(
[Level_ID] => 1347037875
[Name] => HFM-Official Heart Health Guide
[Cancelled] =>
[1347037876] => stdClass Object
(
[Level_ID] => 1347037876
[Name] => HFM-All Access Cardiac Success Club
[Cancelled] =>
)
)
)
)
这是第二个数组:
Array
(
[success] => 1
[levels] => Array
(
[level] => Array
(
[0] => Array
(
[id] => 1347037871
[name] => HFM-Ask the Experts
[_more_] => /levels/1347037871
)
[1] => Array
(
[id] => 1347037874
[name] => HFM-Cardiac Resistance Training Program
[_more_] => /levels/1347037874
)
[2] => Array
(
[id] => 1347037875
[name] => HFM-Official Heart Health Guide
[_more_] => /levels/1347037875
)
[3] => Array
(
[id] => 1347037876
[name] => HFM-All Access Cardiac Success Club
[_more_] => /levels/1347037876
)
)
)
[supported_verbs] => Array
(
[0] => GET
[1] => POST
)
)