RE: [PHP-DB] String manipulation
| From: | Bastien Koert | Date: | Mon, 02 May 2005 13:13:42 +0000 |
| Subject: | RE: [PHP-DB] String manipulation | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-39336@lists.php.net to get a copy of this message | ||
Are you trying to achieve this in the db or for the application? It sounds like the application, in which case I would get the string from the db and then use substr to pull out the various elements.
$first_name = substr($rows['name'],0,1);
$last_name = substr($rows['name'],1);
Bastien
From: "Chris Payne" <cjp@planetoxygene.com> To: <php-db@lists.php.net> Subject: [PHP-DB] String manipulation Date: Mon, 2 May 2005 00:48:58 -0400 Hi there everyone, I'm working with a mysql Db where I have a single string that I have to split into 2 strings, the first character is the first name and I have that split off into it's own variable, but what I need to know is what's the best method to read the string again BUT ignore the first letter as that is already copied into $firstname? So basically I have $firstname defined from the one string, but I have to define $lastname from the SAME string value as the one I used for $firstname, BUT ignoring the first letter but I'm not sure what the best method is to achieve this? Any help would be very appreciated. Chris