I am new to PHP so this may be a simple fix.
I have a text file named textt.txt that looks like this:
South East asia,2222,code1
winter break,3333,code2
My PHP code looks like this:
<?php
$x = file_get_contents('textt.txt');
$y = explode("\r\n", $x);
$z = $y[0];
echo $z;
?>
The outcome of this is:
South East asia,2222,code1
I would like it to return only:
South East Asia.
How can I make this happen?
explode()again on the comma. Your first call toexplode()splits the string by lines, each containing a comma-separated string.