Hi all
I have a question about how to store parsed data into a multidimensional arrays -- I can store items into an array, but multidimensional arrays mystify me a bit. Any help would be greatly appreciated.
I'm storing the images in a table, grouped according to their table and their descriptions, so that later when I call the images, I can display them accordingly. I'm using the Simple HTML DOM Parser. So say I have two tables, one with three images, and another with one. I'd like the resulting to array to look like:
Array
(
[0] => Array
(
[0] => image1.jpg
[1] => 1st Variation Description
)
[1] => Array
(
[0] => image2.jpg
[1] => image3.jpg
[2] => image4.jpg
[3] => 2nd Variation Description
)
)
This is what I have so far:
$html = str_get_html($vartables);
$varinfo = array();
foreach($html->find('table') as $table){
$varinfo[] = $table->innertext;
}
print_r($varinfo);
Which yields:
Array
(
[0] =>
<tr>
<td width=150>
Description1
</td>
<td><a href="image1.jpg">
<img src="image1" height=100 border=1></a>
</td>
</tr>
[1] =>
<tr>
<td width=150>
Description2
</td>
<td><a href="image2.jpg">
<img src="image2.jpg" height=200 border=1></a>
</td>
<td><a href="image3.jpg">
<img src="image3.jpg" height=200 border=1></a>
</td>
<td><a href="image4.jpg">
<img src="image4.jpg" height=200 border=1></a>
</td>
</tr>
)
I'd like to strip out the html and keep the .jpg's and descriptions together in a multidimensional array...unfortunately my newbness is getting the better of me there, I'm researching but running into a roadblock. Thanks in advance for any help.