Back to my original question, on how to check if the next elem starts with a space, if it does, concatenate it to the previous elem. how would you deal with cases where the array has multiple levels.
[1] => Array (
[1] => Packages
[2] => Sources
[3] => Reading package
[4] => Sources
[5] => More Sources
[6] => volatile Sources
[7] => volatile
)
To output:
[2] => Array (
[1] => Packages
[2] => Sources Reading package Sources More Sources
[6] => volatile Sources volatile
)
Will do it for the first space.
for($i = 0; $i < count($array); $i++){
if($array[$i][0] == ' '){
if($i > 0){
$array[$i-1] .= $array[$i];
unset($array[$i]);
}
}
}