[英]php print each line from textarea
我有這個代碼
<textarea rows="4" cols="50" type="text" name="ytburl" /></textarea>
<input type="submit" value="START" name="submit" />
$ytburl = $_POST["ytburl"];
echo 'link '.$ytburl.' is here'
因此,如果在textarea中,我放置2個鏈接:
example.com/11111
example.com/22222
然后我得到這個輸出:
鏈接example.com/11111 example.com/22222在這里
我想得到這個輸出:
鏈接example.com/11111在這里
鏈接example.com/22222在這里
如果只nl2br()
發送文本一樣打印文本,則可以使用nl2br()
函數將所有換行符替換為HTML標記。
但是,最好只打印未過濾的數據,然后將其與strip_tags()
函數結合使用。
echo nl2br(strip_tags($variable));
嘗試這個
<?php
$arrLines = explode(' ', $variable);
foreach($arrLines AS $line){
echo $line . '<br/>';
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.