Jump to content

preg_match question


jeff5656

Recommended Posts

RegEx isn't required here, so i posted a non-regEx version as well

 

$patient = "smith, john";
if (preg_match('/(.*?),/sim', $patient, $regs)) {
$fName = $regs[1];
}
echo $fName;

//OR
echo substr($patient, 0, strrpos($patient, ","));

 

hope they helps

(oh both are untested)

Link to comment
https://forums.phpfreaks.com/topic/162670-preg_match-question/#findComment-858493
Share on other sites

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.