> This is very close.  If the string, "  Testing  ", had multiple spaces, but
> I wanted to convert each space to a "_", then what?  I tried:

There may be a better way, but here is a lengthy one that works.

$checkme = "              this is          it               ";

if(ereg("^( )+", $checkme, $match)) {
   for($i = 0; $i < strlen($match[0]); $i++) {
      $start .= "_";
   }
}
if(ereg("( )+$", $checkme, $match)) {
   for($i = 0; $i < strlen($match[0]); $i++) {
      $end .= "_";
   }
}

$fix = ereg_replace("^( )+", $start, $checkme);
$fix = ereg_replace("( )+$", $end, $fix);

echo "$fix";

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
How do Crays and Alphas handle the POSIX problem?
             -- Larry Wall in <[EMAIL PROTECTED]>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to