Jump to content

[SOLVED] preg_replace Not Working As Desired


JustinK101

Recommended Posts

I am trying to remove everything from a string EXCEPT a-z, A-Z, 0-9. This includes removing white space. Here is the code I am using:

 

$customer_name_test = "Justin's Test, Company";
$customer_name_test = preg_replace("[^a-zA-Z0-9 ]", '', $customer_name_test);
//Should Return JustinsTestCompany, but is returning Justin's Test, Company
echo $customer_name_test;

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.