quote:
Originally posted by Ezra
quote:
Originally posted by -dt-
code:
$string = preg_replace('/\[\[wiki(?:\)([a-zA-Z]+|)\]([a-zA-z0-9_]+)\]/e', 'defL("$1","$2")',$string);
function defL($lang,$title){
if($lang=='')$lang='en';
$title1 = str_replace("_", " ", $title);
return '<a href="http://'.$lang.'.wikipedia.org/wiki/'.$title.'">'.$title1.'</a>';
}
Found a little error, fixed it
Instead of using the parts defined in the tag it made a link like this:
<a href="$lang.wikipedia.org/wiki/$title">$title1</a>
WTf please tell me how it would return a link like that
my code
code:
$string = preg_replace('/\[\[wiki(?:\:|)([a-zA-Z]+|)\]([a-zA-z0-9_]+)\]/e', 'defL("$1","$2")',$string);
function defL($lang,$title){
if($lang=='')$lang='en';
$title1 = str_replace("_", " ", $title);
return "<a href='http://$lang.wikipedia.org/wiki/$title'>$title1</a>";
}
because I use " to contain the string which will parse any varible in that string unlike its brother '
so im not getting how its an error...