loops loops - 10 months ago 56
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.


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

str_replace(',', '.', $form);