I am reading from a MySQL Database.
The field upc
reads as:
811657019822
843018021328
I only want the first numbers; there is a space/carriage return and for some reason I cannot explode it out or trim it out. When I convert to XML it displays as:
<g:gtin>811657019822 843018021328</g:gtin>
Here is what I have tried in PHP and the result:
When I do a var_dump
it shows this:
string(25) "811657019822
843018021328"
Notice how they are not all on one line?
It doesn't appear to be a line break as the XML returns a Carriage Return. Any ideas on what to try to remove everything after the first numbers?
UPDATE
As pointed out by @Don't Panic I have erroneously mistaken my slashes the wrong way and should of only been using \r
.
This is what worked correctly:
explode("\r", $product['upc']);
Explode with '/r/n'
won't work for a couple of reasons. For one you'd need to use a double quoted string, with backslashes instead of forward slashes, like "\r\n"
. But there isn't a \n
, just an \r
.
Try using
explode("\r", $yourString);