note 34391 rejected from function.split by alindeman

From: Date: Fri, 25 Jul 2003 16:06:23 +0000
Subject: note 34391 rejected from function.split by alindeman
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-52645@lists.php.net to get a copy of this message
Note Submitter: darthjarkon@hotmail.com ---- I was working with PHP and javascript to dynamically create popups to display carpet samples. The only major problem was that the naming convention wasn't standard (the carpet name would be passed to the popup and the image file associated with that name would be called, along with echoing the name into parts of the page-- this meant that I would get "snake_skin" or "milk Chocolate") Here's the code I used to fix it: <?php $carpet_name = $_GET[pic]; $splitted = split("_", $carpet_name); if($splitted[1] == NULL){ //this compensates for a carpet name with a <SPACE> //instead of an underscore $splitted = split(" ", $carpet_name); $splitted[0] = strtolower($splitted[0]); echo ucfirst($splitted[0]); echo " "; $splitted[1] = strtolower($splitted[1]); echo ucfirst($splitted[1]); }else{ $splitted[0] = strtolower($splitted[0]); echo ucfirst($splitted[0]); echo " "; $splitted[1] = strtolower($splitted[1]); echo ucfirst($splitted[1]); } ?> recommendations? email me. cheers. -j

« previous php.notes (#52645) next »