$str = '[http://www.phpfreaks.com/]';
$str = trim($str, '');
echo '<a href="' . $str . '">' . $str . '</a>';
Yeah, but this isn't the way i need it..
This will work:
$contents = ':BOF: [http://www.phpfreaks.com/] :EOF:';
preg_match("/(http:\/\/)[a-zA-Z0-9-]+[\._a-zA-Z0-9-]+/i", $contents, $links);
This help too, but what i need is to replace that url inside a variable with the text line, so, when I print that line, its print the link as well.. and not the url alone..
$var = 'this is the text line with [http://www.test.com]
url inside' ;
the trim method don't leave to print this line with the second link.. and the is a better way to me to keep the url safe.. so, i think about use preg_replace, based on your post, caesar..
(If something is wrong, please tell me. I'm learning this language. Thank you)