I'm trying to delete all characters except numbers and letters but it doesn't work for me
public function number10($valor){
$nueva = preg_replace('[^ A-Za-z0-9_-ñÑ]', '', $valor);
echo $nueva;
return $nueva;
/*if($tamañoCadena == 10){
return $tamañoCadena;
}else{
return 'No Válida';
}*/
}
I comment that
/
A-Za-z0-9
to indicate all the groups of values that would be part of the pattern to find^
inside the brackets to indicate that everything that matches those groups of values is what will be negatedCode:
With an output like this:
References