You're just trying to print a list of words, one per line? print join('<br>', explode(' ', 'Why am I trying?'));
or, broken into steps in case you want to deal more with the array: $ar = explode(' ', 'Why am I trying?'); foreach ($ar as $word) { print "<br>$word"; } I didn't look that carefully at your code because it was making my head hurt. Perhaps if you can explain better what you're trying to achieve (if the computer can't figure it out, neither can we) then I could provide more specific and helpful advice. miguel On Wed, 24 Apr 2002, Kirk Babb wrote: > First, here's my code: > <?php > $string="Why am I trying to do this crazy stuff when I should know > better?"; > $array=preg_split("[\s]", $string); > // just a test of the preg_split results > // print_r($array); > $i=0; > $count = count($array); > $container=0; > while ($container <= 20) { > $box = strlen($array[$i]); > $container=$container + $box; > $i++; > } > $returned_string=""; > $j=0; > while ($j <= $i) { > $returned_string .= $array[$j] . " "; > $j++; > } > print $returned_string . "<br>"; > ?> > Works great on the first line, but I'm stuck on printing the remaining part > of the array using some sort of loop. I've tried a few things but get > endless loops. In the end I'd like to make this a function and just give it > the string and the container length as arguments.....can someone give me > some advice? > > THANKS! :) > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php