Search for elements that matches a pattern in PHP
<p>I have a string like <code>sub_category-21,cross_category-23,sub_category-33,sub_category-93,cross_category-69</code>.</p>

<p>I want to obtain the numbers for sub_category and the ones for cross category.</p>

<p>What I've done since now is seperate it in an array:</p>

<pre><code>$categories = explode(",", $_POST["categories"]);

$sub_categories = array();
$cross_categories = array();

foreach($categories as $category)
{

}
</code></pre>

<p>How I can do it?</p>

<p>Thank you in advance!</p>
