Greetings everyone.
I am pretty good when it comes to this type of thing, but for whatever reason I am unable to find, or understand the advanced syntax of preg_match_all(). As I understand it, preg_match_all can take a series of expressions, and create an array element for each match. First match on that line: $array[0][0], Second: $array[0][1] Next line being [1][0] [1][1] respectivly. Am I wrong ?
Assuming I am correct, Here's the Problem. I have a bit of data to sift through from a website, the first field is a set of numbers, and the second is a multi-word phrase. I can parse for each of these by themselves perfectly using the following:
preg_match_all("/[A-z ]*<\/a>/i", $contents, $out);
preg_match_all("/[0-9]+<\/td>/", $contents, $out);
However, as I understand it from the documentation I have been over, no body tells how I can put these two expressions together, so that I might be able to access them as a multi-dimensional array.
Some things report no errors but no results, and some things just bomb. This is an example of how I wish to display only for testing of the code:
The data would look something like this:
213545 Haywood jablowme 323234 Eleanor Gasm 324234 I P Freelie 32423 Hot Dickens Cider
I wold like it to display (for later database entry) as such:
213545 Haywood jablowme
323234 Eleanor Gasm
324234 I P Freelie
324232 Hot Dickens Cider
via the following table: (or approximate therof)
echo "<br>1. ".$out[1][0] . ", " . $out[0][0] . "\n";
echo "<br>2. ".$out[2][0] . ", " . $out[0][1] . "\n";
echo "<br>3. ".$out[3][0] . ", " . $out[0][2] . "\n";
Taken straight from the documentation I have found on the subject here, php.net, and the PHP SQL hardcopy. I also syspect that the table for display may not be entirely correct.
I can figure out how to do this the "Long way around", but I am sure there has got to be some slick piece of code to do just this, as I am seeing a lot of examples that I have not yet come close to using with PHP, and I have been using it for a couple of years now.
Any help or pointers in the right direction would be great, and yes, I have the book "Mastering regular expressions" on order.
Thanks in Advance.
Dan.