You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用PHP提取textarea文本框中的纯数字内容

提取textarea中仅含数字行的PHP实现

需求:有一个textarea,每行内容为数字或名称,需要提取其中仅包含数字的行。

实现代码

<?php 
    $allUsers = $_POST['allusers'];
    foreach(explode("\n", $allUsers) as $line) {
        
        if (is_numeric($line)) {
            echo $line."\n";
        }

    }
?>

测试用textarea示例

<textarea>
156444
978455
amoka
123
auman
</textarea>

内容的提问来源于stack exchange,提问作者egam321

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 16:11:14