Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex not working on returned value
    primarykey
    data
    text
    <p>So I was learning about regex and stuff today and I got it to work how I wanted it but when I tried to put it to use as part of something to get data from a site, it did not work. Interestingly enough if I echoed the raw html that I was retrieving, then put it into the regex as a string manually, it worked fine. Does anyone know why this would happen? Here is the code:</p> <pre><code>preg_match_all('/&lt;img src="images\/cms\/trinket\/(.*).png" \/&gt;&lt;\/a&gt; &lt;div style="width:85px; font-size:14px; font-weight:bold; color:#731c08;"&gt;(.*)&lt;\/div&gt;/iU', snd('test.php'), $matches, PREG_SET_ORDER); </code></pre> <p>snd is a function with curl returning the data which might be causing the problem but I dont know.</p> <p>snd function:</p> <pre><code>function snd($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://whatever.com/'.$url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); $result = curl_exec($ch); curl_close($ch); return $result; } </code></pre> <p>example (newlines added for readability):</p> <pre><code>&lt;div style="width:600px; margin-left:auto; margin-right:auto; text-align:center; position:relative; z-index:1;"&gt; &lt;span style="display:inline-block; width:85px; height:100px;"&gt; &lt;a rel="includes/itemajax.php?id=789&amp;tab=trinket" class="clue"&gt; &lt;img src="images/cms/trinket/789.png" /&gt;&lt;/a&gt; &lt;div style="width:85px; font-size:14px; font-weight:bold; color:#731c08;"&gt;4&lt;/div&gt; &lt;/span&gt; &lt;span style="display:inline-block; width:85px; height:100px;"&gt; &lt;a rel="includes/itemajax.php?id=891&amp;tab=trinket" class="clue"&gt; &lt;img src="images/cms/trinket/891.png" /&gt;&lt;/a&gt; &lt;div style="width:85px; font-size:14px; font-weight:bold; color:#731c08;"&gt;3&lt;/div&gt; &lt;/span&gt; </code></pre> <p> </p> <p>should return: 789,4 and 891,3</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