can any body help me why this solution is not accepted please?
function stop_at($array) {
$out = ‘’;
foreach($array as $item) {
if ($item == 42) {
break;
}
$out .= $item."\n";
} return $out;
}
echo stop_at($arr);
OR
function stop_at($array) {
$r = [];
foreach($array as $item) {
if ($item == 42) {
break;
}
$r[] = $item;
} return $r;
}
print_r(stop_at($arr));
Thanks in advance!