I have a string variable like this: '1111/222/333'
or '1111/222/333/444'
and I want to get an Array like this:
111-222-3333
111-222-
111-
OR
1111-222-333-444
1111-222-333-
1111-222-
1111-
I have tried with $pieces = explode("/", $str);
and:
$str = '1111/222/333/444';
$pieces = explode("/", $str);
for($i=0; $i<count($pieces); $i++) {
$var .= $pieces[$i]."-".$pieces[$i+1];
echo $i." - ".$var."<br>";
}
but I haven't gotten the correct result!
Any help?