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]
それをhtmlリストに変えるためのphpでの最良の方法は何でしょうか?
$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);