Here the code show results.

WWE WWE WWF WWE WWF RAW WWE WWF RAW ECW WWE WWF RAW ECW NXT

But I want to get Results Like.

WWE WWF RAW ECW NXT WWF RAW ECW NXT RAW ECW NXT ECW NXT NXT

Can anyone modify following codes according to my wanting?

Code Is:

<?php $stringSentence = 'WWE WWF RAW ECW NXT SMACKdown'; $stringSentence = preg_replace('/\s+/', ' ', $stringSentence); $buffer = ''; $count = 1; $length = strlen($stringSentence); for ($i = 0; $i < $length; $i++) { if ($stringSentence[$i] !== ' ') { $buffer .= $stringSentence[$i]; } else { //echo ' '.$count++.' '.$buffer.'&lt;/br&gt;'; $pieces = explode(" ", $stringSentence); $first_part = implode(" ", array_splice($pieces, 0, $count++)); echo ''.$first_part.'</br>'; $buffer = ''; } } ?>

Md Rakib Khan's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.