function make_url($string){ $hack = "|(\[url\])(.*?)(\[/url\])|"; $code = "\\2"; return preg_replace($hack,$code,$string); } $data[$nameloop+3] = "[url]http://www.blah.de[/url]"; echo make_url($data[$nameloop+3]);