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);
$salary = preg_replace('/,/', '.', $form);
But yeah, you don't really want to match a pattern but a string which is constant, so simply use str_replace()
.
You can simply use
str_replace(',','.',$form);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With