- print_r: documentation ( source)
<?php
$list_of_lists_of_lists = [[1, 2, [3]], [4, 3, 4, [5, 3, 4]], 3];
$flattened_list = [];
function flatten($l){
foreach ($l as $value) {
if (is_array($value)) {
returnflatten($value);
}else{
$flattened_list[] = $value;
}
}
return $flattened_list;
}
$flattened_list = flatten($list_of_lists_of_lists);
print_r($flattened_list);