I have a list of products codes that i wish to read into an array using php.
the list is to be fetched from a website and has over 700 items looks something like this:
4310ABC
4590DEF
8950GHK
What i want to do is put every code into a php array like so:
php_array ( [0] => 4310ABC
[1] => 4590DEF
[2] => 8950GHK)
This is what i have:
$php_array = file_get_contents('http://anysite.net/product_codes.php');
print_r (explode("\n",$php_array));
But my result is :
Array ( [0] => 4310ABC
4590DEF
8950GHK)
I have tried explode, preg_split('/[\n\r]+/', $php_array); but nothing seems to do the trick. Can anyone give me some pointers? thanks!
file_get_contents()call? Are you sure that it's using\nas a separator, and not<br>, for example?$php_arraybefore you explode and examine it.<p></p>for example. right click, view source'<br>'not"\n"