loops loops - 1 year ago 106
PHP Question

Replace Comma(,) with Dot(.) RegEx php

i am trying this code but i get this error:

No ending delimiter '/' found

$form = " 2000,50";
$salary = preg_replace('/',', '.'/', $form); // No ending delimiter '/' found
echo $salary;

I am not sure about the regex validation.

Answer Source

Regex is overkill for replacing just a single character. Why not just do this instead?

str_replace(',', '.', $form);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download