php - Turning a paragraph of phrases into a list -


i'd use preg_replace or ereg replace, turn paragraph of phrases such 1 below:

this 1 2 3 4 

to list, such 1 below:

  • this one
  • this two
  • this three
  • this four
  • notice i'm targeting spaces before upper case letters.

    $word = "this 1 2 3 four"; $arr = explode (" " , $word); $lines = array_chunk($arr,3); foreach($lines $line)  echo implode (" ", $line)."<br>"; 

    Comments