Mit $ Variablen in preg_replace in PHP

Ähmm... wie benutze ich Variablen in einem Aufruf von preg_replace?

Diese hat nicht funktioniert:

foreach($numarray as $num => $text)
    {
        $patterns[] = '/<ces>(.*?)\+$num(.*?)<\/ces>/';
        $replacements[] = '<ces>$1<$text/>$2</ces>';
    }

Ja, die $num ist vorangestellt ein Pluszeichen. Ja, ich will "tag the $num as <$text/>".

InformationsquelleAutor Steve | 2009-09-09
Schreibe einen Kommentar