0

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.

3
  • What have you tried? See ask advice, please. Commented Feb 8, 2013 at 5:33
  • Just show me your code where u r printing the array,.... Commented Feb 8, 2013 at 5:35
  • This is not CakePHP question, it is primary subject from PHP Commented Feb 8, 2013 at 10:00

3 Answers 3

2

Just use array_shift

array_shift($array)
Sign up to request clarification or add additional context in comments.

Comments

2

I prefer using array_shift in such cases.

Comments

1

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.

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.