Jump to content

include everything up to the comma


jeff5656

Recommended Posts

One way (of many) would be:

 

$newlastname = $row['name'];
if (preg_match('/^[^,]+(?=,)/', $row['name'], $match)) {
    $newlastname = $match[0];
}

 

If you're using PHP 5.3 then you could instead use strstr and even if not, basic string functions might be easier, cleaner, etc. in this case.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.