You do not need to use regular expressions.
str_replace(), ',' '.', intval() floatval() . strstr() '.' , intval() floatval()
:
$row = array('Unspecified risk', 'Yes', '8', '3', '2', '13', 'none', '-1,49', '-2,51', '-1,46', '-1,54');
function toNumber($target){
$switched = str_replace(',', '.', $target);
if(is_numeric($target)){
return intval($target);
}elseif(is_numeric($switched)){
return floatval($switched);
} else {
return $target;
}
}
$row = array_map('toNumber', $row);
var_dump($row);
str_replace() , float, , , is_numeric() < - , , , ..
is_numeric , float text intval() floatval() ( , , true ).
$row = array_map('toNumber', $row); .
xD