I have a multidimensional array that looks like the one below:
Array
(
[results] => Array
(
[0] => Array
(
[hotel_code] => 15ad7a
[checkout] => 2018-04-26
[checkin] => 2018-04-24
[destination_code] => 1c6e0
[products] => Array
.... etc ....
)
[1] => Array
(
[hotel_code] => 193c6c
[checkout] => 2018-04-26
[checkin] => 2018-04-24
[destination_code] => 1c6e0
[products] => Array
.... etc ....
)
Wanting to create a simple pagination of the results, taking from the array 15 records at a time, through the following code I can recover the first 15 records.
$i = 0;
foreach($data['results'] as $key=>$val){
$i++;
$selez_hotel_code = '' . $val['hotel_code'] . '';
if($i == 15) break;
}
Now, how can I get the next 15 values from the array? I tried to start the foreach directly from record 15, setting it as follows
$i = 0;
foreach($data['results'][14]['hotel_code'] as $val){
$i++;
$selez_hotel_code = '' . $val . '';
if($i == 15) break;
}
but it did not work.
for loopfor this type of situation