<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] # 問題描述 比如我們數組是這樣的 ~~~ $messages=[ 'Should be working now', 'If you see', 'But there should not have blank' ]; ~~~ 我們想把他轉化成makdown格式的 ~~~ $messages=[ '- Should be working now /n', '- If you see /n', '- But there should not have blank /n' ]; ~~~ # 常規寫法 ~~~ $comment=''; foreach ($messages as $message){ $comment.="- {$message} \n"; } dump($comment); ~~~ 我們在數組第一個下標前面下個-,然后其他的元素前面加/n和- ~~~ $comment='- '.$messages[0]; foreach (array_slice($messages,1) as $message){ $comment.=" \n- {$message}"; } dump($comment); ~~~ # collection ## 第一種 ~~~ $comment=collect($messages)->map(function($value){ return "- {$value} \n"; }); ~~~ 這樣出來每一個都是數組,我們要把他拼接成字符串,用''來拼接 ~~~ $comment=collect($messages)->map(function($value){ return "- {$value} \n"; })->implode(''); ~~~ 我們看到最后一個也有個\n這是多余的,我們可以用mb_substr來截取 `$comment=mb_substr($comment,0,-1);` 從第一個元素截取到倒數第一個 ## 第二種 之前我們發現collection要用''來把他連成字符串,其實我們可以在每個元素中間用\n來連接的 ~~~ $comment=collect($messages)->map(function($value){ return "- {$value}"; })->implode("\n"); dump($comment); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看