Hi, I’m new to the community.
I’d like some help on splitting data from a .txt file into two pieces.
This is what I have so far.
[php]$location = ‘/file.txt’;
$data = file($location);
$line = trim($data[array_rand($data)]);
list($a, $b) = preg_split("+", $line, 2);
echo $a,$b;[/php]
In the text file it looks like this
Peter+1200 Griffin Avenue
Luis+1553 Atlantic Blvd
Zac+4500 Island Blvd
and so on…
The script is suppose to grab a random line and split that line into two variables, a and b, so then $a and $b can be used on that page in different areas…
So far it seems that preg_split isn’t grabbing the information from the text file but looking in the same page (index.php)
the error I’m getting…
[b]Warning[/b]: preg_split() [function.preg-split]: No ending delimiter '+' found in [b]/public_html/index.php[/b] on line [b]44[/b]
If you could help a newbie out it would be much appreciated!
~ 123z