php explode() delimiter issue
Posted
by
mumis2012
on Stack Overflow
See other posts from Stack Overflow
or by mumis2012
Published on 2011-11-18T17:48:28Z
Indexed on
2011/11/18
17:51 UTC
Read the original article
Hit count: 164
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?
Thanks!
© Stack Overflow or respective owner