Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple DOM Parser IF not working
    primarykey
    data
    text
    <p>Can anyone tell why the second if statement pulling the soldby name wouldn't work properly?</p> <p>What I want it to do is name pull the alt attribute from the image, if there is an image for the seller - which works. But if there isn't an image logo, there is a bold tag with the seller name which I want to be inserted in the same place in the array that the alt tag would be.</p> <p>The HTML I am working with is: http:// amazon.com/gp/offer-listing/B002UYSHMM</p> <p>Can anyone help?</p> <p>Thank you!</p> <pre><code>$item = array(); foreach ($html-&gt;find('div.resultsset table tbody.result tr') as $article) { if ($article-&gt;find('span.price', 0)) { // get retail $item[$retail.$i++] = $article-&gt;find('span.price', 0)-&gt;plaintext; // get soldby if ($article-&gt;find('ul.sellerInformation img', 0)) { $item[$soldby.$j++] = $article-&gt;find('ul.sellerInformation img', 0)-&gt;getAttribute('alt'); } else { $item[$soldby.$j++] = $article-&gt;find('ul.sellerInformation li a b', 0)-&gt;plaintext; } $ret['SellerInfo'] = $item; } } </code></pre> <p>Here is the array I get out of my code above:</p> <pre><code> Array ( [0] =&gt; Array ( [Retail] =&gt; $219.88 [SoldBy] =&gt; J&amp;R Music and Computer World ) [1] =&gt; Array ( [Retail] =&gt; $234.21 [SoldBy] =&gt; PORTABLE GUY ) [2] =&gt; Array ( [Retail] =&gt; $235.73 [SoldBy] =&gt; The Price Pros ) [3] =&gt; Array ( [Retail] =&gt; $234.74 [SoldBy] =&gt; GizmosForLife ) [4] =&gt; Array ( [Retail] =&gt; $230.00 [SoldBy] =&gt; ) [5] =&gt; Array ( [Retail] =&gt; $198.73 [SoldBy] =&gt; ) [6] =&gt; Array ( [Retail] =&gt; $240.72 [SoldBy] =&gt; ) [7] =&gt; Array ( [Retail] =&gt; $248.99 [SoldBy] =&gt; onSale ) ) </code></pre> <p>You can see that it is missing SoldBy for:</p> <p>STEPHS GREAT BOOK TREASURES </p> <p>Diakonos23</p> <p>OptimumHouse</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