Home > Back-end >  php how to get all values array but array_values not working?
php how to get all values array but array_values not working?

Time:11-01

how to get all values array but set all keys the same name ex : this is my array

but i need remove this key .. I have used array_values() .. but not working

enter image description here

CodePudding user response:

Seems like you want to grab all the arrays inside the item keys? Using array_column and specifying the item as the key will return the arrays inside each item key in a new array. If that is what you're after? The question was kind of hard to understand IMHO.

array_column($array, 'item');

This will return an array on the following structure.

Array
(
    [0] => Array
        (
            [name] => ttt
            [price] => 100
            [quantity] => 1
        )

    [1] => Array
        (
            [name] => sss
            [price] => 100
            [quantity] => 1
        )

    [2] => Array
        (
            [name] => vvv
            [price] => 100
            [quantity] => 1
        )
)

Here's a demo showing it working.

  •  Tags:  
  • php
  • Related