Re: [PHP] insert space to a string (newbie)

2001-09-08 Thread Ryan Fischer

You wrote:
> I have a simple question...
> How can a space inserted to a string after the 3rd char ??
> 
> washington   ->>  was hington 

$str = 'washington';
$str = ereg_replace('^(.{3})(.*)$', '\\1 \\2', $str);

-- 
 -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/



-- 
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]




Re: [PHP] insert space to a string (newbie)

2001-09-08 Thread rm

Maybe something like:

$word="washington";
$length=strlen($word);

$a=substr($word,0,3);
$b=substr($word,3,$length-3);

$string=$a." ".$b;

print $string;

you might want to test for the length of $word first
to make sure $word has more than 3 characters


--- Andras Kende <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have a simple question...
> How can a space inserted to a string after the 3rd
> char ??
> 
> washington   ->>  was hington 
> 
> 
> Thanks :)
> 
> 
> Andras
> 
> 
> -- 
> 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]
> 


__
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

-- 
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]