View Single Post
Old 01-23-2013, 04:38 PM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,653
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
That's the right idea, but not quite what they are looking for. Sounds like they want to remove everything to the right and including the first + sign.
There are several ways. I'd use one of the ones below given the simple criteria:
PHP Code:
$aParts explode('+'$str);
print 
$aParts[0]; 
Would be the easiest.
PHP Code:
$sFirst strtok($str'+');
print 
$sFirst
Is another easy one and probably slightly better on memory.

There are several ways to accomplish this; it is one of the pros of being a string based language. I would not recommend using pcre when you are simply striping based off of another character.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote