- print_r: documentation ( source)
<?php
$i = 0; // menghitung loop
$j = 0; // key untuk $data
$conton = [1, 2, 3, 4, 5, 6, 7];
foreach($contoh as $c) {
$temp[$i] = $c;
$i++;
if( ($i % 3) == 0) {
$data[$j] = $temp[$i];
$j++;
}
}
print_r($temp);
print_r($data);