我有一个由带有中继器的表单创建的大型数组,因此该数组可以无限大。我需要:
- 1. 搜索数组
- 2.获取[field_18]的所有值
- 3. 输出一个包含所有值的数组('-5', '-1', ect )
Array
(
[field_22] => Mid-Distance Free
[field_25] => Array
(
[0] => 1
)
[field_23] => Its a freestyle workout
[field_6] => Array
(
[0] => Array
(
[field_7] => 1
[field_8] => 0
[field_9] => 0
[field_10] => Array
(
[0] => Array
(
[field_11] => 6
[field_12] => 50
[field_13] => jumping jacks
[field_14] =>
)
[1] => Array
(
[field_11] => 2
[field_12] => 20
[field_13] => pushups
[field_14] =>
)
[acfcloneindex] => Array
(
[field_11] => 1
[field_12] => 1
[field_13] => pushups
[field_14] =>
)
)
)
[acfcloneindex] => Array
(
[field_7] => 1
[field_8] => 0
[field_9] => 0
[field_10] => Array
(
[acfcloneindex] => Array
(
[field_11] => 1
[field_12] => 1
[field_13] => pushups
[field_14] =>
)
)
)
)
[field_17] => Array
(
[0] => Array
(
[field_7] => 1
[field_8] => 0
[field_9] => 0
[field_10] => Array
(
[0] => Array
(
[field_11] => 5
[field_12] => 100
[field_13] => Freestyle
[field_14] => Descend 1-5
[field_18] => 5
)
[1] => Array
(
[field_11] => 10
[field_12] => 50
[field_13] => Drill
[field_14] => Choice
[field_18] => 5
)
[2] => Array
(
[field_11] => 1
[field_12] => 400
[field_13] => Freestyle
[field_14] => Negative Split
[field_18] => -20
)
[acfcloneindex] => Array
(
[field_11] => 1
[field_12] => 25
[field_13] => Butterfly
[field_14] =>
[field_18] =>
)
)
)
[acfcloneindex] => Array
(
[field_7] => 1
[field_8] => 0
[field_9] => 0
[field_10] => Array
(
[acfcloneindex] => Array
(
[field_11] => 1
[field_12] => 25
[field_13] => Butterfly
[field_14] =>
[field_18] =>
)
)
)
)
[field_19] => Array
(
[0] => Array
(
[field_7] => 1
[field_8] => 0
[field_9] => 1
[field_10] => Array
(
[0] => Array
(
[field_11] => 20
[field_12] => 100
[field_13] => Freestyle
[field_14] => Hold 500 race pace
[field_18] => -5
)
[1361771245813] => Array
(
[field_11] => 1
[field_12] => 75
[field_13] => Butterfly
[field_14] =>
[field_18] =>
)
[acfcloneindex] => Array
(
[field_11] => 1
[field_12] => 125
[field_13] => Butterfly
[field_14] =>
[field_18] =>
)
)
)
[acfcloneindex] => Array
(
[field_7] =>
[field_8] => 0
[field_9] => 0
[field_10] => Array
(
[acfcloneindex] => Array
(
[field_11] => 1
[field_12] => 25
[field_13] => Butterfly
[field_14] =>
[field_18] =>
)
)
)
)
[field_21] => Array
(
[acfcloneindex] => Array
(
[field_7] =>
[field_8] => 0
[field_9] => 0
[field_10] => Array
(
[acfcloneindex] => Array
(
[field_11] =>
[field_12] => 25
[field_13] => Butterfly
[field_14] =>
[field_18] =>
)
)
)
)
)
我试图遍历所有的键,但不知道从那里去哪里。这是我使用的代码。
function array_keys_multi(array $array)
{
$keys = array();
foreach ($array as $key => $value) {
$keys[] = $key;
if (is_array($array[$key])) {
$keys = array_merge($keys, array_keys_multi($array[$key]));
}
}
return $keys;
}