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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -