How to get array value of multidimensional array in Opencart

I am using the Opencart framework and I have configured the Opencart mobile API. The thing is, I get an array like this

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
        )

So, I want to get the last or final value of an array,

in this list of arrays this should be my last array

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
        )
    )

Someone help me solve this problem.

+4
source share
1 answer

There are many ways to do this, but there may be some difference.

end($array)or $array[count($array) -1]leave the original array unchanged.

array_pop($array) will remove the last element from the original array.

+4
source

Source: https://habr.com/ru/post/1691217/


All Articles