Hi All,
I hope you can help me with this, it's wrecking me poor head:
$pizza = "piece1
piece2
piece3
piece4
piece5
piece6";
$pieces = explode("\n", $pizza);
foreach($pieces as $thing)
{
print "'".$thing."'";
}
/*
The above code will print out this:
'piece1
''piece2
''piece3
''piece4
''piece5
''piece6'
Note that the delimiter (actual newline) DOES get included in the resulting string! WTF!!!
*/
as you can see, my $pizza var is split into parts by newline characters. When I explode it using the newline as a delimiter, I would expect that the newline wouldn't be included in the result. If I change all those newlines to spaces, and use space as the delimiter, I don't get the spaces in the result.
Can someone explain why the newlines are included in the result? My real problem is when reading flat files. I try exploding by newline, and the above occurs.
Thanks in Advance!
Az.