0

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?

1
  • You shouldn't work on arrays in Laravel... work in Collections and then on collection use pluck('field')->toArray(); for example: User::all()->pluck('email')->toArray(); Commented Sep 19, 2016 at 15:09

1 Answer 1

1

You can use the methods provided by php.

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

$keys and $values will both be arrays

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.