View Full Version : BBCode help

08-07-2008, 05:01 PM

Just wondering if someone could help me write in a snippet of code which would make sure the link in between the [img] tags is infact an image.

$search = array('/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[url\=(.*?)\](.*?)\[\/url\]/is', '/\[center\](.*?)\[\/center\]/is', '/\[img\](.*?)\[\/img\]/is');
$replace = array('<b>$1</b>', '<i>$1</i>', '<u>$1</u>', '<a href="$1" target="_blank">$2</a>', '<center>$1</center>', '<img src="$1" border="0">');

How would i test to see if it was an image? I'm assuming i check the $1 variable, but how would i test to make sure they are using the [img] tag and not the [url] tag :X

Any help would be appriciated

08-07-2008, 05:12 PM
One way is to run the image through getimagesize().

08-07-2008, 05:50 PM
Thanks. How would i know they are using [img] code tags though :X