note 34391 added to function.split
| From: | darthjarkon at hotmail dot com | Date: | Fri, 25 Jul 2003 15:58:09 +0000 |
| Subject: | note 34391 added to function.split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52644@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.split.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34391
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34391&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34391&report=yes