Theres something I’m missing, could someone enlighten me? For some reason it just WONT replace the spaces with dashes. The titler function works outside of the bbcode class, formats the string inside the bbcode class fine, but won’t swap out the spaces! WRYYY!
titler.php:
[php]<?php
class BBCode{
public function parse($str) {
$simple_search = array(
'/\[title\](.*?)\[\/title\]/is',
'/\[highlight\](.*?)\[\/highlight\]/is',
'/\[anchor\](.*?)\[\/anchor\]/is',
);
$simple_replace = array(
$this->titler('\\1'),
'<span class="highlight">$1</span>',
'<a name="$1"></a>',
);
$str = preg_replace ($simple_search, $simple_replace, $str);
return $str;
}
public function titler($in){
$sec = preg_replace("@\s@is", "-", $in);
$out = '<a name="'.$sec.'" href="#'.$sec.'"><span class="title">'.$in.' - ></span></a>';
return $out;
}
}
?>[/php]
titler.php
[php]<?php
include_once(“titler.php”);
$bbcode = new BBCode();
$txt = $bbcode->parse("[title]this is a test[/title]some words
omg HTML
");echo $txt;
?>[/php]
thanks for reading. =]