for foreach textarea循环的php
我需要从TextArea中通过行数据获取行,并将其分组为三个偶头。如何修复它?
我的代码
<form method="POST" action="test.php">
<textarea name="textarea" style="width:100%; height: 20vh"></textarea><br /><br />
<input type="submit" class="button" style="float: right; cursor:pointer;" value="">
</form>
<?php
$lines = explode("\n", $_POST['textarea']);
if ( !empty($lines) ) {
foreach ( $lines as $line ) {
for ($i=1;$i<=3;$i++) {
echo trim( $line )."<br/>";
}
}
}
I need get line by line data from textarea and group it for three cointainers. How to fix it?
My code
<form method="POST" action="test.php">
<textarea name="textarea" style="width:100%; height: 20vh"></textarea><br /><br />
<input type="submit" class="button" style="float: right; cursor:pointer;" value="">
</form>
<?php
$lines = explode("\n", $_POST['textarea']);
if ( !empty($lines) ) {
foreach ( $lines as $line ) {
for ($i=1;$i<=3;$i++) {
echo trim( $line )."<br/>";
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须检查是否先发布null是否为null ...,因为帖子是无效的...
似乎Textarea将被编码HTML ...
所以你能尝试改变
you have to check if POST not null first... because POST is null able...
Seems textarea will be encode html...
so could you try to change