将制表符分隔的文本从文本区域分解为准备插入语句的数组
我创建了一个文本区域,以便用户可以插入与特定模块关联的类代码。用户将从 Excel 中复制并粘贴到 html 文本区域中。例如:
当粘贴到文本区域时,上面的内容由制表符分隔。在 php 中,我如何将每一行转换为单独的数组?例如,谢谢,任何帮助将不胜感激。
array(1)
(
[0] => "moduleA"
[1] => "class1"
)
array(2)
(
[0] => "moduleA"
[1] => "class2"
)
array(3)
(
[0] => "moduleA"
[1] => "class3"
)
I've created a textarea so users can insert class codes associated to a particular module. The user will copy from excel and paste into a html textarea. for example:
When pasted in the textarea the above is separated by tabs. In php how would i convert each row into a seperate array? e.g. Thanks, any help would be appreciated.
array(1)
(
[0] => "moduleA"
[1] => "class1"
)
array(2)
(
[0] => "moduleA"
[1] => "class2"
)
array(3)
(
[0] => "moduleA"
[1] => "class3"
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我的经验,textarea 中的新行(默认情况下)是
\n
。您可以对每一行使用\n
进行内爆/爆炸(取决于您想要的)。例如explode("\n", $data);
From my experiences, a new row in textarea (by default) is a
\n
. You can implode/explode (depends on what you want) with\n
for every row. e.gexplode("\n", $data);