Значи имам следния bbcode с регулярен израз
Нали добавям си снимка, но въпроса ми е как да направя, ако тя е по голяма от 350px да я смалява на width="350". Само това немога да направя
Код:
function bbcodes($text) {
$bbcode_text = $text;
$bbcode_text = preg_replace('/\[b\](.*)\[\/b\]/', '<b>$1</b>', $bbcode_text);
$bbcode_text = preg_replace('/\[u\](.*)\[\/u\]/', '<u>$1</u>', $bbcode_text);
$bbcode_text = preg_replace('/\[url\](.*)\[\/url\]/', '<a href="$1" target="_blank">$1</a>', $bbcode_text);
$bbcode_text = preg_replace('/\[url=(.*)\](.*)\[\/url\]/', '<a href="$1" target="_blank">$2</a>', $bbcode_text);
$bbcode_text = preg_replace('/\[quote\](.*)\[\/quote\]/', '<div id="quote">$1</div>', $bbcode_text);
$bbcode_text = preg_replace('/\[quote="(.*)\"](.*)\[\/quote\]/', '<br>$1 каза:<div id="quote">$2</div>', $bbcode_text);
$bbcode_text = preg_replace('/\[mail\](.*)\[\/mail\]/', '', $bbcode_text);
$bbcode_text = preg_replace('/\[img\](.*)\[\/img\]/', '<img src="$1" alt="image">', $bbcode_text);
return $bbcode_text;
}