How can I get string before two and above characters [string] ? PHP -
$string1 = "2-2-2000-2000-";
how can following result? for $output1 -> 2 $output2 -> 2-2 $output3 -> 2-2-2000 $output4 -> 2-2-2000-2000
does want?
$array = explode('-', $string1); ($i = 1; $i < count($array); $i++) { echo 'for $output' . $i . ' -> ' . implode('-', array_slice($array, 0, $i)) . "\n"; }
Comments
Post a Comment