3
I made the following function in php that takes a string, and returns a new string containing only the numbers of the received string.
I’m just not able to concatenate each number to this new string. I tried the following:
function extraiSoNumsDeString($string){
//Definindo uma String
$result="";
for($i=0; $i<strlen($string); $i++){
$j = substr($string, $i,1);
if ($j>="0" and $j<="9") $result=.$j;
}
//Retorna uma string contendo apenas o número da conta.
return $result;
}
Only the interpreter has syntax error on this line:
if ($j>="0" and $j<="9") $result=.$j;
saying I can’t use this point to concatenate $j to $result.
Does anyone know how I could do this concatenation? I must return a single string in this function...
Would not be
.= $j
instead of= .$j
?– Inkeliz