question about explode()

From: Date: Fri, 28 Sep 2001 06:55:04 +0000
Subject: question about explode()
Groups: php.general 
Request: Send a blank email to php-general+get-69130@lists.php.net to get a copy of this message
say that: $fone = "1234567890"; i have a db with fone number stored as numeric values just like that. I can use explode (".", $fone); to get an array with one digit per ... single unit of array. what i'd *like* to do (for the purpose of formatting) is do something equivalent to explode ("...", $fone, 3); to explode the string into 3 ... single units of array: fone[0] containing 123 fone[1] conatining 456 and the remaining 4 values (yay php4 and your limit parameter) get stuck in the last: fone[2] conaining 7890. then i can just print ("($fone[0]) fone[1]-fone[2]"); so is there a syntactical way to tell explode to split at every character? explode ("."%3) or some wacky, freaky thing? other such clean solutions would also be accepted. basically, what i have now of: explode (".", $f); print ("($f[0]$f[1]$f[2]) $f[3]$f[4]$f[5]-$f[6]$f[7]$f[8]$f[9]"); is just heinous to look at. or is re-inputting the values in the db as 123-456-7890 my best option? thanks, all you helpful folk. --kevin

« previous php.general (#69130) next »