Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP替换"|&引用;html列表的符号<;李>;_Php_Html_Regex - Fatal编程技术网

PHP替换"|&引用;html列表的符号<;李>;

PHP替换"|&引用;html列表的符号<;李>;,php,html,regex,Php,Html,Regex,我从数据库中得到了这个值 10:00 | 10:15 | 10:30 我需要将此符号替换为html列表 像这样: <li><input class="left" type="text" value="10:00" /><div class="del right ">x</div></li> <li><input class="left" type="text" value="10:15" /><div cl

我从数据库中得到了这个值

10:00 | 10:15 | 10:30

我需要将此符号替换为html列表
  • 像这样:

    <li><input class="left" type="text" value="10:00" /><div class="del right ">x</div></li>
    <li><input class="left" type="text" value="10:15" /><div class="del right ">x</div></li>
    <li><input class="left" type="text" value="10:30" /><div class="del right ">x</div></li>
    
  • x
  • x
  • x
  • 使用
    explode()
    ,然后从生成的数组构建列表:

    $str = "10:00|10:15|10:30";
    $out = "";
    
    foreach ( explode( "|", $str ) as $value ) {
      $out .= "<li>{$value}</li>";
    }
    
    echo "<ul>{$out}</ul>";
    
    $str=“10:00 | 10:15 | 10:30”;
    $out=“”;
    foreach(分解(“|”,$str)为$value){
    $out.=“
  • {$value}
  • ”; } 回声“
      {$out}
    ”;
    其结果是:

    <ul>
        <li>10:00</li>
        <li>10:15</li>
        <li>10:30</li>
    </ul>
    
    • 10:00
    • 10点15分
    • 10:30
    从这里添加您的输入很容易:

    foreach ( explode( "|", $str ) as $value ) {
        $out .= "<li>
                     <input class='left' type='text' value='{$value}' />
                     <div class='del right'>x</div>
                 </li>";
    }
    
    foreach(分解(“|”,$str)为$value){
    $out.=“
  • x
  • ”; }
    留给你的是:

    <ul>
        <li>
            <input class='left' type='text' value='10:00' />
            <div class='del right'>x</div>
        </li>
        <li>
            <input class='left' type='text' value='10:15' />
            <div class='del right'>x</div>
        </li>
        <li>
            <input class='left' type='text' value='10:30' />
            <div class='del right'>x</div>
        </li>
    </ul>
    
    • x
    • x
    • x
    使用
    explode()
    ,然后从生成的数组构建列表:

    $str = "10:00|10:15|10:30";
    $out = "";
    
    foreach ( explode( "|", $str ) as $value ) {
      $out .= "<li>{$value}</li>";
    }
    
    echo "<ul>{$out}</ul>";
    
    $str=“10:00 | 10:15 | 10:30”;
    $out=“”;
    foreach(分解(“|”,$str)为$value){
    $out.=“
  • {$value}
  • ”; } 回声“
      {$out}
    ”;
    其结果是:

    <ul>
        <li>10:00</li>
        <li>10:15</li>
        <li>10:30</li>
    </ul>
    
    • 10:00
    • 10点15分
    • 10:30
    从这里添加您的输入很容易:

    foreach ( explode( "|", $str ) as $value ) {
        $out .= "<li>
                     <input class='left' type='text' value='{$value}' />
                     <div class='del right'>x</div>
                 </li>";
    }
    
    foreach(分解(“|”,$str)为$value){
    $out.=“
  • x
  • ”; }
    留给你的是:

    <ul>
        <li>
            <input class='left' type='text' value='10:00' />
            <div class='del right'>x</div>
        </li>
        <li>
            <input class='left' type='text' value='10:15' />
            <div class='del right'>x</div>
        </li>
        <li>
            <input class='left' type='text' value='10:30' />
            <div class='del right'>x</div>
        </li>
    </ul>
    
    • x
    • x
    • x

    您可以使用|作为除味器对每个结果进行除味。

    您可以使用|作为除味器对每个结果进行除味。

    您可以使用

    $input = '10:00|10:15|10:30';
    $list = explode('|', $input);
    
    而不是使用foreach在数组上迭代

    foreach ($list as $li) {
        echo '<li />' . $li;
    }
    
    foreach($li){
    回音“
  • ”。$li; }
  • 您可以使用

    $input = '10:00|10:15|10:30';
    $list = explode('|', $input);
    
    而不是使用foreach在数组上迭代

    foreach ($list as $li) {
        echo '<li />' . $li;
    }
    
    foreach($li){
    回音“
  • ”。$li; }
  • 尝试使用:

    <?php
        $result = explode('|','10:00|10:15|10:30');
        foreach($result as $single)
        {
            echo '<li><input class="left" type="text" value="'.$single.'" /><div class="del right ">x</div></li>'."\r\n";
        }
    ?>
    
    
    
    尝试使用:

    <?php
        $result = explode('|','10:00|10:15|10:30');
        foreach($result as $single)
        {
            echo '<li><input class="left" type="text" value="'.$single.'" /><div class="del right ">x</div></li>'."\r\n";
        }
    ?>
    
    
    
    显示您尝试的内容。到底什么不起作用。这里有一个提示让你开始。使用
    explode
    然后循环使用itUse$items=explode(“|”),$str,然后通过$items[index]使用每个项目显示您尝试了什么。到底什么不起作用。这里有一个提示让你开始。使用
    explode
    然后循环使用itUse$items=explode(“|”和$str),然后通过$items[index]使用每个项目