Is it possible to make preg_replace parse the variables inside a function?
I am looking to transform a [shorturl]full-url[/shorturl]
into a clickable short url.
I want something like this:
$code = array(
...
'#\[shorturl\]((?:ftp|https?)://.*?)\[/shorturl\]#i' => '<a href="'.file_get_contents("http://...some_api?url=$1").'">$1</a>',
...
)
$result = preg_replace(array_keys($code), array_values($code), $text);
But this don't works... The api does receive the "$1" as the url rather than the actually url.
Any thoughts?