Re: help using ereg_replace()

From: Date: Mon, 14 Jan 2002 16:07:19 +0000
Subject: Re: help using ereg_replace()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-80468@lists.php.net to get a copy of this message
Hi Erik, > "$phone" is a 10-digit string. > I would like the output to be > $phone = "(555) 555-5555"; you don't need regex to do that. just insert add "(" to the beginning of $phone, add ") " to the 4th position, and "-" to the 4th position from behind, using substr_replace() function. anyway if you insist on using regex: preg_replace("/(\d{3})(\d{3})(\d{4})/", "(\\1) \\2-\\3", $arr); -- Jimmy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Everything loses its value when overly used, including love.

« previous php.general (#80468) next »