简体   繁体   中英

Explode Textarea each line in list item

I am trying to get each new line of textarea as a list item with explode and foreach. I have tried \\n, \\n\\r, \\r\\n and PHP_EOL but nothing works. Here is my function

function dt_explode_list($option,$explode_key,$ul_class) {

    $tacs = explode($explode_key, get_option($option));

    echo '<ul class="'.$ul_class.'">';

    foreach ($tacs as $tac) {

        echo '<li>'.$tac.'</li>';   

    }

    echo '</ul>';

}

Calling with this

<?php dt_explode_list('dt_condition_apply','\n','tick-list'); ?>

New lines need to be in double quotes

<?php dt_explode_list('dt_condition_apply',"\n",'tick-list'); ?>

See "Double Quoted" http://php.net/manual/en/language.types.string.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM