A regex that converts text lists to html in PHP

后端 未结 4 2106
谎友^
谎友^ 2021-01-05 08:51

I\'m trying to code a regexp to convert a block of text:

* List item
* Another list item

to html:

4条回答
  •  攒了一身酷
    2021-01-05 08:58

    Why don't you store the first regex in an array with preg_match_all, and glue it like this:

    $list='
    • '; $list .= implode('
    • ',$arr_regex); $list .= '
    ';

提交回复
热议问题