Have been working on a small project, and have gotten stuck at a part that I am trying to get working. Not sure if I am taking the wrong type of approach for it, and there is a better way, but here we go.
I have data in a text file that is written and read to. example: (values are separated by a \t)
S1684 This is a status share 20/9/2012 share;
What I am doing is searching the file, and returning anything that matches as a part of the array. I have the search working fine, and can return each line that contains the search query, only problem is exploding the results so that I can properly format what I return. This is the main chunk that deals with it.
if(preg_match_all($pattern, $data, $matches)){
echo "<h3>Results:</h3>";
echo implode("<p>
", $matches[0])."</p>";
foreach ($matches as &$value) {
$date =0;
list($statusCode, $status, $share, $date, $like, $comment, $share) = explode("\t", $date);
echo "<h4>Status:".$status."</h4>";
echo "<h4>Status Code:".$statusCode."</h4>";
}
}
The error I receive are undefined offset errors, so how exactly would I be able to explode (or split the array result in any other way) to echo it properly?
Any help is much appreciated thanks.