function foo($str,$num) {
     return preg_replace('/ {'.$num.',}/',str_repeat(' ',$num),$str);
 }

On Fri, 9 Aug 2002, Henry wrote:

> Hi All,
>
> Are there standard functions for removing multiple spaces (or even better
> limiting contiguous space to specified lengths)?
>
> i.e
>
> foo("Hello     peeps, happy   times",1) -> "Hello peeps, happy times"
> foo("Hello     peeps, happy   times",0) -> "Hellopeeps,happytimes"
> foo("Hello     peeps, happy   times",2) -> "Hello  peeps, happy  times"
> (notice single space between "," and "h")
>
> Can I do it with reg exp?
>
> TIA
>
> Henry
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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

Reply via email to