Testing for matches within a string
<p>I have a script that grabs all of the hash tags from a string and then stores them in an array, well what happens next is determined by whether or not there are any hash tags in the string. How do I create an if statement to only run the code if there are indeed hash tags in the string being tested. </p>

<p>Here is what I have tried:</p>

<pre><code>&lt;?php

$string= "Went for an awesome bike";

echo $string . "&lt;/br&gt;&lt;/br&gt;";

preg_match_all('/#(\w+)/',$string, $matches);


if ($matches != 0) {

    foreach ($matches[1] as $tag) {

        echo $tag . "&lt;/br&gt;&lt;/br&gt;";

    }

}
else {

    echo "There are no tags here!!";

}


?&gt;
</code></pre>

<p>I cant get it to echo out the failure message? What could I be doing wrong?</p>

<p>Thanks!</p>
