Re: Strip alternating spaces in first word of paragraph

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Burhan Khalid wrote:
<?php

  $string = 'E n d l e s s insanity here!';

  $letters  = explode(" ",$string);
  foreach ($letters as $key => $letter)
  {
    if (strlen($letter) == 1)
    {
      //Possible letter of our first word
      $word .= $letters[$key];
    } else {
      $split_point = $key;
    }
  }
  echo "Original : ".$string."\n";
  echo "Word     : ".$word."\n";
  echo "Modified : ".$word." ";
  echo implode(" ",array_slice($letters,$split_point-1))."\n";
?>

Thanks for the example, looks like it might just work! -- Aaron Gould Programmer/Systems Administrator PARTS CANADA

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux