0

I have this array,

$bookings[] = array(
    'booking_id' => '1', 
    'client_name' => 'John', 
    'client_firstname' => 'Peter', 
    'days' => array(
        array(
            'day_id' => '2016-11-23',
            'room_id' => '2'
        ),
        array(
            'day_id' => '2016-11-24',
            'room_id' => '2'
        ),
        array(
            'day_id' => '2016-11-25',
            'room_id' => '4'
        )
    )
)

I'm looking for looping into the days array with PHP.

How is it possible please ?

Thanks for your help.

1
  • what have you try? Commented Nov 22, 2016 at 1:59

1 Answer 1

1

demo

 <?php
    $bookings[] = array(
        'booking_id' => '1', 
        'client_name' => 'John', 
        'client_firstname' => 'Peter', 
        'days' => array(
            array(
                'day_id' => '2016-11-23',
                'room_id' => '2'
            ),
            array(
                'day_id' => '2016-11-24',
                'room_id' => '2'
            ),
            array(
                'day_id' => '2016-11-25',
                'room_id' => '4'
            )
        )
    );
    foreach($bookings as $booking)
    {
      foreach($booking['days'] as $day)
      {
        echo $day['day_id'];
        echo "\n";
      }
    }
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.