php 截取 云仓单来源于ID576158中的数字
可以使用正则表达式来截取云仓单中的数字。使用preg_match函数可以匹配到符合条件的数字。
下面是一个示例代码:
<?php
$yunCangDan = '云仓单(来源于ID:576158)';
preg_match('/\d+/', $yunCangDan, $matches);
$number = $matches[0];
echo $number; // 输出: 576158
?>
这段代码使用了正则表达式/\d+/来匹配到云仓单中的数字。然后使用preg_match函数将匹配结果存储在$matches数组中,并取出第一个匹配到的数字。最后输出结果为576158。
原文地址: https://www.cveoy.top/t/topic/i66u 著作权归作者所有。请勿转载和采集!