We have mobile numbers stored in db in format 0789 121 928
We need to remove the blank spaces from the number so it is 0789121928
This is what I have used before to remove ‘,’ in $ fields, and am trying to modify.
<?php
$value1A = $row_person_select['mobile'];
$value1A = preg_replace("|,|","",$value1A); // Strips out commas in incoming value ie 2,340.00 > 2340.00
$totalA = $value1A;
echo $totalA;
?>
I have tried the obvious of replacing the ‘,’ with ‘ ‘ but does not work?
Ideas? Thank you.
You don’t need a regular expression here.
str_replaceis sufficient if you just want to remove spaces.But just to answer the actual question, you can use
"|\s|"with preg_replace to remove any whitespace characters.