Luis
Luis

Reputation: 31

Get data from multidimensional array in laravel

I have an array like this:

   {#184 ▼
      +"Column_name1": "value1"
      +"Column_name2": "value2"
      +"Column_name3": "value3"
      +"Column_name4": "value4"
      +"Column_name5": "value5"
      +"Column_name1": "value6"
    }
#187
    ...

I have got the array from MsSQL using a raw query with procedure

I want to get an array with the DB columns names

I expect something like this:

['Column_name1','Column_name2'...]

How could I split the array?

Upvotes: 0

Views: 627

Answers (1)

Carlos
Carlos

Reputation: 1331

You can use the methods provided by php.

$keys = array_keys($array);
$values = array_values($array);

$keys and $values will both be arrays

Upvotes: 1

Related Questions