PHP 将字符串中的数字转化为数组
标签:article 数组 size 字符 sdn pre http tps str
$str =‘现在是2019年11月18日下午17点25分‘;
$result=‘‘;
$arr=[];
for($i=0;$i<strlen($str);$i ){
if(is_numeric($str[$i])){
$result.=$str[$i];
}else{
if($result!="") {
$arr[] = $result;
$result="";
}
}
}
打印数据:
Array
(
[0] => 2019
[1] => 11
[2] => 18
[3] => 17
[4] => 25
)
参考链接:https://blog.csdn.net/jiangnanqbey/article/details/81354968
PHP 将字符串中的数字转化为数组
标签:article 数组 size 字符 sdn pre http tps str
温馨提示: 本文由杰米博客推荐,转载请保留链接: https://www.jmwww.net/file/biancheng/12244.html
- 上一篇:Python基础
- 下一篇:node真的是单线程模式吗