regex - preg_replace php image messup -
im trying bbcode image work. have problems it.
what in code wrong , why?
i have input:
[img]http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg[/img]
and be:
<img src="http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg">
but result is:
`q: how can make work properly?
full code:
function parsebb($body,$userid = false, $user2 = false) { $find = array( "@\n@", "@[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]@is", "/\[url\=(.+?)\](.+?)\[\/url\]/is", "/\[b\](.+?)\[\/b\]/is", "/\[i\](.+?)\[\/i\]/is", "/\[u\](.+?)\[\/u\]/is", "/\[farge\=(.+?)\](.+?)\[\/farge\]/is", "/\[size\=(.+?)\](.+?)\[\/size\]/is", "/\[font\=(.+?)\](.+?)\[\/font\]/is", "/\[boks\=venstre\](.+?)\[\/boks\]/is", "/\[boks\=hoyre\](.+?)\[\/boks\]/is", "/\[boks\=midten\](.+?)\[\/boks\]/is", "/\[img\](.+?)\[\/img\]/is", "/\[email\](.+?)\[\/email\]/is", "/\[midten\](.+?)\[\/midten\]/is", "/\[venstre\](.+?)\[\/venstre\]/is", "/\[hoyre\](.+?)\[\/hoyre\]/is", ); $replace = array( "<br />", "<a href=\"\\0\">\\0</a>", "<a href=\"$1\" target=\"_blank\">$2</a>", "<strong>$1</strong>", "<em>$1</em>", "<span style=\"text-decoration:underline;\">$1</span>", "<font color=\"$1\">$2</font>", "<font size=\"$1\">$2</font>", "<span style=\"font-family: $1\">$2</span>", "<div align=\"left\" style=\"text-align:center; width:50%; \">$1</div>", "<div align=\"right\" style=\"text-align:center; width:50%;\">$1</div>", "<div align=\"center\" style=\"text-align:center; width:50%;\">$1</div>", "<img src=\"$1\">", "<a href=\"mailto:$1\" target=\"_blank\">$1</a>", "<div style=\"text-align:center;\">$1</div>", "<div style=\"text-align:left;\">$1</div>", "<div style=\"text-align:right;\">$1</div>", ); $body = htmlspecialchars($body); $body = preg_replace($specialcodes, $specialcodesreplace, $body); return $body; }
the problem @
"@[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]@is"
pattern, [img] ... [/img] matching just, comment them , try again, repleaced in form or put pattern line end of array
Comments
Post a Comment