Search a regex in PHP
<p>I am trying to search a text string in PHP. For this i am loading the complete webpage source into a variable using </p>

<pre><code>$filename = "http://google.com/";
$filehandle = fopen($filename, "rt");
$contents = fread($filehandle, 10000);
</code></pre>

<p>Now to read the data inside the span id we have :</p>

<pre><code>&lt;span style="font-size:18px" id="countdown"&gt;4d 19h 34m 43s&lt;/span&gt;
</code></pre>

<p>I have written the peice of code but it is not working for me:</p>

<pre><code>$string = "id\=\"countdown\"";

if(strstr($contents,$string)) {
echo "found it.";
} else {
echo "not found.";
}
</code></pre>

<p>i wish to use some operator like (.+) we can use in PERL where if we make a string match with the syntax </p>

<p><strong>~/abc(.+)ghi/</strong> </p>

<p>then data between abc,ghi is assigned to variable $1.</p>
