} /** * @var array $args 参数:type:音乐类型;href:链接地址 */ $args = array( 'type' => (!empty($match[2]) ? $match[2] : 'direct'), 'href' => (!empty($match[4]) ? $match[4] : '') ); $result = ''; if (empty($args['href'])) { return ''; } else { $GLOBALS['tillMusicPlayer_exist'] = true; $music_id = strip_tags($args['href']); $music_id_array = explode(',', $music_id); $result .= '
' . ''; } return $result; }; /* ==========【扩展短代码结束】========== */ } /** * 将BBCode转换成HTML * * @param string $str 含有BBCode的字符串 * @param bool $escapeHTML 将特殊字符转换为 HTML 实体 * @param bool $nr2br 换行转换成\
标签 * @return string 转换成HTML的字符串 */ public function toHTML($str, $escapeHTML = false, $nr2br = false) { if (!$str) return ''; //return $str; if ($escapeHTML) { $str = htmlspecialchars($str); } else { $str = str_replace('  ',' ',$str); $str = str_replace('"','"',$str); } foreach ($this->bbcode_table as $key => $val) { $str = preg_replace_callback($key, $val, $str); } if ($nr2br) $str = preg_replace_callback("/\n\r?/", function ($match) { return "
"; }, $str); return $str; } }