Re: adding a space every 4 chars
| From: | Jason Wong | Date: | Fri, 12 Nov 2004 13:20:06 +0000 |
| Subject: | Re: adding a space every 4 chars | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201816@lists.php.net to get a copy of this message | ||
On Friday 12 November 2004 04:49, Justin French wrote:
> What's the quickest way to add a space every four characters?
>
> Eg 123456789 becomes 1234 5678 9
No idea whether it's the quickest (in terms of cpu time):
$doo = '123456789';
$dah = preg_replace('/(\d{4})/', '\\1 ', $doo);
echo $dah;
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Stupid, n.:
Losing $25 on the game and $25 on the instant replay.
*/