0

I have this array

Array
(
[first_information] => Array
    (
        [0] => 10
        [1] => 12
    )

[rows] => 1
[0] => Array
    (
        [data_1] => 1
        [data_2] => 2
        [data_3] => 3
        [data_4] => 4
        [data_5] => 5
    )

)

How am I supposed to show only the [first_information] content's.

I have tried with this code

foreach($row['first_information'] as $first)  
   echo $first; 

But shows only '12' which is the second element of the array.

Thank you in advance.

2
  • 1
    That should work, (foreach($row['first_information'] as $first) {echo $first;}). Are you 100% sure your array looks like that? Commented Nov 23, 2014 at 23:53
  • SOLVED! echo $row['first_information'][0].' '.$row['first_information'][1] Commented Nov 24, 2014 at 0:00

1 Answer 1

1

You are doing something wrong (not shown in question, probably wrong var). The code below working as expected (http://codepad.org/NDxhEBdY):

$row = array(
    'first_information' => Array(10,12),
    'rows' => 1,
     0 => Array(
        'data_1' => 1,
        'data_2' => 2,
        'data_3' => 3,
        'data_4' => 4,
        'data_5' => 5
    )
);

foreach($row['first_information'] as $first)  
    echo $first; 
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.