数组:
tableView:cellForRowAtIndexPath:
我想做什么:
dequeueReusableCellWithIdentifier
我想创建一个包含所有Array(
[0] => Array(
[0] => Array(
[type] => CHAMPION_KILL
[timestamp] => 888477
[position] => Array(
[x] => 3001
[y] => 13152
)
[killerId] => 5
[victimId] => 6
[assistingParticipantIds] => Array(
[0] => 1
[1] => 4
)
)
[1] => Array(
[type] => ITEM_PURCHASED
[timestamp] => 2357
[participantId] => 10
[itemId] => 3303
)
)
[1] => Array(
[0] => Array(
[type] => CHAMPION_KILL
[timestamp] => 889522
[position] => Array(
[x] => 13123
[y] => 4564534
)
[killerId] => 1
[victimId] => 4
[assistingParticipantIds] => Array(
[0] => 8
[1] => 2
)
)
[1] => Array(
[type] => ITEM_PURCHASED
[timestamp] => 2507
[participantId] => 8
[itemId] => 4750
)
)
)
数组的数组。但它必须是动态的,因为主阵列并不总是相同的。所以
Array(
[0] => Array(
[type] => CHAMPION_KILL
[timestamp] => 888477
[position] => Array(
[x] => 3001
[y] => 13152
)
[killerId] => 5
[victimId] => 6
[assistingParticipantIds] => Array(
[0] => 1
[1] => 4
)
)
[1] => Array(
[type] => CHAMPION_KILL
[timestamp] => 889522
[position] => Array(
[x] => 13123
[y] => 4564534
)
[killerId] => 1
[victimId] => 4
[assistingParticipantIds] => Array(
[0] => 8
[1] => 2
)
)
)
无法工作。
答案 0 :(得分:2)
遍历您的阵列并搜索您想要的内容:
$resultArray = array();
foreach($yourMainArray as $arrays) {
if (is_array($arrays)) {
foreach($arrays as $array) {
if (isset($array['type']) && $array['type'] == 'CHAMPION_KILL') {
$resultArray[] = $array;
}
}
}
}
答案 1 :(得分:2)
我建议你遍历数组并检查孩子是否符合标准。
示例:
,
您只需将$ mainArray替换为您想要的那个。 并且$ resultArray将是您所期望的。
您可以在此处查看代码段:PHPFiddle Code