I have an Excel file with values as follows.
avi|boom|
ben |boom|
I upload the file and use phpExcel to read and get values from each cell. The whitespaces before avi and after ben how do I remove them in php. I tried using the trim function but data is stored in database with whitespaces.
trim($sheet->getCell('B'.$row )->getValue());
data still gets stored with whitespaces.
The additional whitespace is a non-breaking whitespace character (xA0), not a standard value included in php trim(). You can remove it using the following trim modification.
trim(iconv("UTF-8","ISO-8859-1",$sheet->getCell('B'.$row )->getValue())," \t\n\r\0\x0B\xA0");
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