As mentioned, thank you!
$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));
Extract numbers only
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
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));
Extract numbers only