Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - BBCode parser - Parse both bbcode link tag and not tagged link
    text
    copied!<p>I need to do this :</p> <p>when a user insert a BBCode tag, with preg_replace and regex i do some trasformation.</p> <p>e.g. </p> <pre><code>function forumBBCode($str){ $format_search=array( '#\[url=(.*?)\](.*?)\[/url\]#i' ); $format_replace=array( '&lt;a class="lforum" target="_blank" href="$1"&gt;$2&lt;/a&gt;' ); $str=preg_replace($format_search, $format_replace, $str); $str=nl2br($str); return $str; } </code></pre> <p>now i want also this : when a user insert a normal text with a link, this must be trasformed too. i can't do this trought preg_replace function, because if i write a code as</p> <pre><code>$format_search '#(www\..*?)#i' $format_replace '&lt;a class="lforum" target="_blank" href="$1"&gt;$1&lt;/a&gt;' </code></pre> <p>it will convert the link 2 time (in the [url] and when the link is without this tag).</p> <p>so i think to this function :</p> <pre><code> function checkLinks($string) { $arrelab=""; $arr=split(' |\r\n', $string); for($i=0; $i&lt;sizeof($arr); $i++) { echo $i." - ".$arr[$i]."&lt;br/&gt;"; if ((strpos($arr[$i], 'www.')!==false) or (strpos($arr[$i], 'http://')!==false) or (strpos($arr[$i], 'ftp://')!==false)) { if (strpos($arr[$i], '[url=')===false) { $arr[$i]='&lt;a class="lforum" target="_blank" href="'.$arr[$i].'"&gt;'.$arr[$i].'&lt;/a&gt;'; } } $arrelab=$arrelab." ".$arr[$i]; } return $arrelab; } </code></pre> <p>the problem is that i need a split as for the newline, as for the empty space. any help would be appreciated.</p> <p>p.s. sorry for my bad english :)</p> <p>cheers</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload