php - How to convert a multidimensional array into single dimensional array without using foreach method -


this question has answer here:

how convert multidimensional array single dimensional array without using foreach method

array     (        [0] => array            (                [opportunityid] => 5                [id] => 89                [discountedpackagecost] => 89990.00                [discountedaddoncost] => 61000.00                [title] => big title okayyyyyyy???????            )         [1] => array            (                [opportunityid] => 42                [id] => 90                [discountedpackagecost] => 45592.00                [discountedaddoncost] => 0.00                [title] => test book            )      ) 

i need key->"id" form each rows.

any default methods available in php??

i expect result this.

array(2) { [0]=> string(2) "89" [1]=> string(2) "90" } 

you can use array_column in php 5.5 or newer

$array = array(                array(                   'id' => 1,                   'name' => 'foo'                ),                array(                   'id' => 2,                   'name' => 'bar'                )          );  $ids= array_column($array, 'id'); print_r($ids); 

read more


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -