I have a database with prices from lots of different products. They're all in this format: £25,000.
What I want is the following: 25000.
I figured I must use a foreach loop and use str_replace, but I can't seem to find a way to delete the pound sign and the comma.
I also have a few rows where the prices are missing, they're in the database as following: £00
Again, I want to delete the pound sign. So that must be a different loop I guess?
Could you explain how it must be done?
try this
$new_array = str_replace(array("£",","),array("",""),$old_array);
This will remove comma and £
(if present), in all your rows at once
update your_table
set your_column = replace(replace(your_column, '£', ''), ',', '')
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