preg_replace('/\[img=(.+)\]/', '<img src="$1">', $text)
if (@imagecreatefromstring(file_get_contents($arr[1]))){
return 'гуд';
}else{
return 'не гуд';
}
$routput = "Bad code!";
$ioutput = "<img src='%s'/>";
$pattern = "/^\[[img|IMG]+=\'(.*).(jpg|png|gif)\'\]\$/";
$allowed = array("image/jpeg", "image/png", "image/gif");
$bbimage = "[IMG='http://www.hdiphonewallpapers.us/phone-wallpapers/phone/12963B64236440-2J38.jpg']";
if (preg_match($pattern, $bbimage)) {
try {
$path = preg_replace($pattern, "$1.$2", $bbimage);
$size = getimagesize($path);
$mime = (string) $size['mime'];
if ($mime && in_array($mime, $allowed, true)) {
$routput = sprintf($ioutput, $path);
}
} catch (Exception $e) {}
}
echo $routput;