What PHP function can find the numbers in 2c653c8e716f42b67c7aba493ce54dbc?
take123
take123 2018-03-04 22:27:18
0
8
1487

As mentioned, thank you!

take123
take123

reply all(5)
辉
$content = '2c653c8e716f42b67c7aba493ce54dbc';
preg_match_all('/[0-9]/',$content, $match);
print_r( $match );

One line of code to get all the numbers

黄天敏

$a = '12ddas45fd8a9fgd6a4f08d9af';
$c ='';
for ($i = 0;$i<strlen($a);$i++){
$b=substr( $a,$i,1);
if (ord($b)<=57 && ord($b)>=48){
$c .= $b;
}
}
echo $c;

Convert the string into ascii code because the range of numbers in ascii code is 48-57. Just match it

大辉狼
<?php
$str = '200c653c8e716f42b67c7aba493ce54dbc';
//将字符串拆分成数组
$arr =str_split($str);
$str2 = '';

for($i=0;$i<count($arr);$i++){
    //判断是不是数字
    if (is_numeric($arr[$i])) {
        //拼接
        $str2.=$arr[$i];
    }
}
echo $str2;


——

You can write a piece of code to achieve it

$arr ​​=str_split('2c653c8e716f42b67c7aba493ce54dbc');

for($i=0;$i<count($arr) ;$i++){

$arr[$i]=(int)$arr[$i];

}

$int=implode(',', array_filter($arr));


  • reply There is a problem with the code. If there is a "0" in the string, I can't find it.
    大辉狼 author 2018-03-05 13:03:45
  • reply is_numeric($str) determines whether it is a number, just make a judgment;
    MrSwan author 2018-03-05 13:17:53
  • reply 0 will be empty by default. This code is fine and has been tested.
    —— author 2018-03-05 14:46:48
郭飞

Extract numbers only

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template