Jump to content

[SOLVED] simple preg_match help


scarhand

Recommended Posts

This is shorter:

$string = "name_number";
preg_match("/(.+)_/", $string, $result);
echo $result[1];

 

But I'm not a regex expert. Could be something better. The reason why that didn't work for you in your earlier post was because you forgot the 3rd preg_match argument (assigning result somewhere).

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.