php-如何在Opencart中获取多维数组的最后一个数组的值

我正在使用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)将删除原始数组中的最后一个元素.

上一篇:PDF文件优缺点


下一篇:Javascript注意事项四【提高循环性能的策略】