Dobrý deň,
potrebooval by som zmeniť bbcode v tomto scripte:
potrebujem tam len bbcode [url], sám si s tým neviem poradiť ďakujem
Kód:
function wordwrap2($str,$maxLen,$break)
{
$arrBBCode = array("\[b\]","\[/b\]","\[i\]","\[/i\]","\[u\]","\[/u\]");
$arrStr = $arrIndexBBCode = array();
$rest = false;
while(strlen($str)>0) {
$start = $end = $tmpEnd = 0;
$start = strpos($str,'[',$end);
if($start!==false) {
$end = strpos($str,']',$start);
if($end!==false) {
$tmpEnd = $end;
if($start>0) {
$arrStr[] = substr($str,0,$start);
}
$item = substr($str,$start,$end-$start+1);
$isRegularBBCode = false;
foreach($arrBBCode as $bbcode) {
if(eregi("^".$bbcode."$",$item)) {
$isRegularBBCode = true;
$arrIndexBBCode[] = count($arrStr);
break;
}
}
if($isRegularBBCode || count($arrStr)==0) {
$arrStr[] = $item;
} else {
$arrStr[count($arrStr)-1] .= $item;
}
$str = substr($str,$end+1);
} else {
$rest = true;
}
} else {
$rest = true;
}
if($rest) {
$arrStr[] = substr($str,$tmpEnd);
break;
}
}
foreach($arrStr as $i => $item) {
if(!in_array($i,$arrIndexBBCode)) {
$arrItem = explode(' ',$item);
foreach($arrItem as $z => $word) {
if(strlen($word)>$maxLen) {
$arrItem[$z] = wordwrap($word,$maxLen,$break,true);
}
}
$arrStr[$i] = implode(' ',$arrItem);
}
}
return implode('',$arrStr);
}