我有一个
PHP数组,它具有不同数量的元素和不同类型的关联,如下所示:
$example =
Array
(
[0] => 12345
[1] => 100
[2] => Some String
...
[17] => 2
[18] => 0
[type] => Some String
[inst] => Array
(
[0] => Some String
)
[method] => Some String
)
$other =
Array
(
[0] => 45678
[1] => 250
[2] => Some String
...
[8] => 7
[9] => -2
[inst] => Array
(
[0] => Some String
[1] => Some String
)
)
我要做的是获取这些数组中的最后一个数字索引以及之前的一些数字索引.就像在第一个例子中,我想得到$example [18]而在第二个例子中我想要返回$other [9].
在命名的关联发挥作用之前,我使用了count($array)-1.