我正在使用Opencart框架,并且我定制了Opencart移动API。问题是我得到了这样的数组
Array (
[0] => Array (
[product_option_id] => 228
[product_option_value_id] => 20
[option_id] => 13
[option_value_id] => 49
[price] => 280.0000
[value] => 1000.00000000
[name] => please select weight
[type] => select
)
)
Array (
[0] => Array (
[product_option_id] => 228
[product_option_value_id] => 20
[option_id] => 13
[option_value_id] => 49
[price] => 280.0000
[value] => 1000.00000000
[name] => please select weight
[type] => select
)
[1] => Array (
[product_option_id] => 228
[product_option_value_id] => 21
[option_id] => 13
[option_value_id] => 50
[price] => 140.0000
[value] => 500.00000000
[name] => please select weight
[type] => select
)
)
Array (
[0] => Array (
[product_option_id] => 228
[product_option_value_id] => 20
[option_id] => 13
[option_value_id] => 49
[price] => 280.0000
[value] => 1000.00000000
[name] => please select weight
[type] => select
)
[1] => Array (
[product_option_id] => 228
[product_option_value_id] => 21
[option_id] => 13
[option_value_id] => 50
[price] => 140.0000
[value] => 500.00000000
[name] => please select weight
[type] => select
)
)
Array (
[0] => Array (
[product_option_id] => 228
[product_option_value_id] => 20
[option_id] => 13
[option_value_id] => 49
[price] => 280.0000
[value] => 1000.00000000
[name] => please select weight
[type] => select
)
[1] => Array (
[product_option_id] => 228
[product_option_value_id] => 21
[option_id] => 13
[option_value_id] => 50
[price] => 140.0000
[value] => 500.00000000
[name] => please select weight
[type] => select
)
[2] => Array (
[product_option_id] => 232
[product_option_value_id] => 32
[option_id] => 13
[option_value_id] => 50
[price] => 25.0000
[value] => 500.00000000
[name] => please select weight
[type] => select
)
所以,我想获得最后或最后的数组值,
在给定的数组列表中,这必须是我的最终数组
Array (
[0] => Array (
[product_option_id] => 228
[product_option_value_id] => 20
[option_id] => 13
[option_value_id] => 49
[price] => 280.0000
[value] => 1000.00000000
[name] => please select weight
[type] => select
)
[1] => Array (
[product_option_id] => 228
[product_option_value_id] => 21
[option_id] => 13
[option_value_id] => 50
[price] => 140.0000
[value] => 500.00000000
[name] => please select weight
[type] => select
)
[2] => Array (
[product_option_id] => 232
[product_option_value_id] => 32
[option_id] => 13
[option_value_id] => 50
[price] => 25.0000
[value] => 500.00000000
[name] => please select weight
[type] => select
)
)
有人帮我解决了这个问题。
许多方法,但可能会有一些差异。
end($array)
或$array[count($array) -1]
保持原始数组不变。
array_pop($array)
将从原始数组中删除最后一个元素。