Note that there are some explanatory texts on larger screens.

plurals
  1. POParse HTML table into multidimensional array
    primarykey
    data
    text
    <p>I'd like to store images (which are in tables) in a multidimensional array, grouped <strong>according to their table</strong> and their descriptions, so that later when I call the images, I can display them accordingly. For example, say I have two tables, one with three images, and another with one.</p> <p>I'd like the resulting array to look like:</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; image1.jpg [1] =&gt; 1st Variation Description ) [1] =&gt; Array ( [0] =&gt; image2.jpg [1] =&gt; image3.jpg [2] =&gt; image4.jpg [3] =&gt; 2nd Variation Description ) ) </code></pre> <p><em>Edit</em> Thanks for the recommendations on the Simple HTML Dom Parser. Here's what I've done so far, and I've reached a bit of a plateau as to how to store the data in the exact structure I need.</p> <pre><code>$html = str_get_html($vartables); $varinfo = array(); foreach($html-&gt;find('table') as $table){ $varinfo[] = $table-&gt;innertext; } print_r($varinfo); </code></pre> <p>This gives me something to the effect of:</p> <pre><code>Array ( [0] =&gt; &lt;tr&gt; &lt;td width=150&gt; Description1 &lt;/td&gt; &lt;td&gt;&lt;a href="image1.jpg"&gt; &lt;img src="image1" height=100 border=1&gt;&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; [1] =&gt; &lt;tr&gt; &lt;td width=150&gt; Description2 &lt;/td&gt; &lt;td&gt;&lt;a href="image2.jpg"&gt; &lt;img src="image2.jpg" height=200 border=1&gt;&lt;/a&gt; &lt;/td&gt; &lt;td&gt;&lt;a href="image3.jpg"&gt; &lt;img src="image3.jpg" height=200 border=1&gt;&lt;/a&gt; &lt;/td&gt; &lt;td&gt;&lt;a href="image4.jpg"&gt; &lt;img src="image4.jpg" height=200 border=1&gt;&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; ) </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload