RE: [PHP] suffixSwap function

From: Date: Fri, 06 Oct 2000 04:57:30 +0000
Subject: RE: [PHP] suffixSwap function
Groups: php.general 
Request: Send a blank email to php-general+get-18860@lists.php.net to get a copy of this message
Surely you want explode? function suffixSwap($nameString, $x, $pattern=".") { $arr = explode($pattern, $nameString); return ($arr[0] . $x); } What about if there is more than one . in the string. eg x.y.jpg? -----Original Message----- From: Theodore Jones [mailto:theoj@transport.com] Sent: October 6, 2000 12:26 PM To: David Robley; php-general@lists.php.net Subject: [PHP] suffixSwap function Hey all, I've go this function: function suffixSwap($nameString, $x) { $pattern = "."; $arr = split($pattern, $nameString); echo ($arr[0]) . $x; } which should take a file name like "stardust.jpg" and tack on a new suffix ".mpg" to make "stardust.mpg". I'm trying to split my functions passwed string (nameString), by matching the patter ".", but can't seem to get it to work? Anyone know what could be going on. It just spits out ".mpg" for every value I try with my function call: suffixSwap("stardust.jpg", ".mpg") Thanks much if anyone can offer pointer on my regular expression use...? ~ Theo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#18860) next »