J
J
jacksparrow2015-12-04 19:28:46
PHP
jacksparrow, 2015-12-04 19:28:46

How to remove non-removable spaces when parsing PHPExcel?

There is an unloading of Sberbank, which must be parsed and entered into the database. In this case, some values ​​are recalculated. In the numerical graph of the excel, the number looks like 12,000.00, respectively, earlier when parsing the html version of the download, the code gave
str_replace([' ', ','], ['', '.'], $str) the result is 12000.00 with which everything worked. Now spaces are not removed in any way even by such a perverse construction - str_replace([" ","\t","\n","\r","\0","\x0B","\xA0"],' ',$str); The question is how to remove them.
Tried all reasonable variants of the game with encoding, does not help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2015-12-04
@thewind

You will remove everything except digits and commas with a regex. And then replace the comma with a dot.

P
Philipp, 2015-12-04
@zoonman

Try like this

$str = str_replace(',', '', $str);
$str = preg_replace('/[^\d\.]+/', '', $str);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question