PHP array doesnt recognise the variable value
<p>Please read the code below and comments to see what I'm trying to do. Its hard to explain in a paragraph.</p>

<pre><code>$url_fixx = 'home/sublink/group-view/product/catview1'; 
// What my variable holds. MY GOAL IS: I want to omit group-view, product and catview1 from this so I use the trick below. 
</code></pre>

<p>catview has a random number at the end so I use the code below to find the number at the end and it outputs "catview1" in this case</p>

<pre><code>$string = $url_fixx;
$matches = array();
if (preg_match('#(catview\d+)$#', $string, $matches)) {
    $catViewCatch = ($matches[1]);
 }
// I got this from http://stackoverflow.com/a/1450969/1567428

$url_fixx = str_replace( array( 'group-view/', 'product', 'catview1' ), '', $url_fixx );
// this outputs what I want. 
</code></pre>

<p>MY QUESTION IS : </p>

<pre><code>//When I replace "catview1" with $catViewCatch, the whole str_replace doesnt work. 
$url_fixx = str_replace( array( 'group-view/', 'product', $catViewCatch), '', $url_fixx );
</code></pre>

<p>Why is that? and what am I doing wrong? </p>

<p>PS: Also my url sometimes changes to something like this.<br>
    $url_fixx = 'home/sublink/group-view/anotuer-sublink/123-article'</p>

<p>How can I tackle all these ?</p>
