I want to extract the ID which is the first integer in the string below:
ID:40021223
CSQ(0-31): 31
Online
I only want the to get 40021223
I want to extract the ID which is the first integer in the string below:
ID:40021223
CSQ(0-31): 31
Online
I only want the to get 40021223
$str = 'ID:40021223'; //pass any string
echo $output = getID($str);
function getID($str) {
$res = explode(':',$str); //split string with :
if(in_array('ID',$res)) { //if array contain Id then it will give the exact output else null
return $res[1];
} else {
return null;
}
}