Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设有一个这样的 bbcode 列表:
[list] [*]something [*]something2 [/list]
php中将其转换为html列表的最佳方法是什么?
$string = '[list] [*]something [*]something2 [/list]'; $regex = array( '/\[list\](.*?)\[\/list\]/is' => '<ul>$1</ul>', '/\[\*\](.*?)(\n|\r\n?)/is' => '<li>$1</li>' ); echo preg_replace(array_keys($regex), array_values($regex), $string);