preg_replace and array values
===

I need to convert every number inside the curly brackets ('{}') to a hyperlink. The thing is, the string can contain multiple patterns.

    $text = 'the possible answers are {1}, {5}, and {26}';
    preg_match_all( '#{([0-9]+)}#', $text, $matches );

The output array is like this
 
    Array ( 
    [0] => Array ( [0] => {1} [1] => {5} [2] => {26} ) 
    [1] => Array ( [0] => 1 [1] => 5 [2] => 26 ) 
    )

Here is my current code.


    $number=0;
    return preg_replace('#{([0-9]+)}#','<a href="#$1">>>'.$matches[1][$number].'</a>',$text);
    $number++;

But output is like
    
    The possible answers are
    <a href="#1">1</a>, <a href="#5">1</a>, and <a href="#26">1</a>

Only '1' ($matches[1][0]) is being fetched.

How do I fix this?