Sibin Francis
Sibin Francis

Reputation: 601

How to convert an Array of array to array in cakephp

I have a problem when converting an array of array to array when I debug a variable named $todaysdata, It shows below output,

             Array
                 (
                   [0] => Array
                        (
                           [Requestcard] => Array
                             (
                                 [id] => 954
                                 [userprofile_id] => 14
                                 [userprofile_name] => Syed Imran
                                 [sex] => male

                              )

                         )

                )

But actually i want the output in in the given format

                           Array
                               (
                                 [Requestcard] => Array
                                    (
                                      [id] => 954
                                      [userprofile_id] => 14
                                      [userprofile_name] => Syed Imran
                                      [sex] => male

                                     )

                               )

If anybody knows. Please help me.

Upvotes: 0

Views: 87

Answers (3)

user1957109
user1957109

Reputation:

I prefer using array_shift in such cases.

Upvotes: 2

William Buttlicker
William Buttlicker

Reputation: 6000

Just use array_shift

array_shift($array)

Upvotes: 2

Warren
Warren

Reputation: 108

The correct syntax for solving the example that you've given would be similar to:

$result_array = $original_array[0];

If you have multiple arrays to move up, you might want to consider PHP's array_merge() function.

Upvotes: 1

Related Questions