I need to convert strings of the form
\"a b c\"
into arrays of the form
Array
(
[0] => a
[1] => a b
[2] =
And this question will not be complete without the recursive answer:
function get_substrings($str){
$len = strlen($str);
$ans = array();
$rest = array();
for ($i = 1; $i <= $len; $i++) {
$ans[] = substr($str, 0, $i);
}
if($str){
$rest = get_substrings(substr($str, 1));
}
return array_merge($ans, $rest);
}
$subs = get_substrings("abc");
print_r($subs);