I have to import a txt file in my SQL database but the negative numbers are written with minus at the end (for ex : 11.719,88- or 13.791,47-).
When I import, negative numbers are positive. All my calcultate datas are false...
In my preprocess function (php), I tried many way to manage it but no success. Here is my function :
$char = $row['column_numbers'];
$char_array = str_split($char);
$last_char = end($char_array);
if($last_char == '-'){
$char_array = preg_replace('/[-]/', '', $char_array);
$char_array = '-'.$char_array;
return $char_array;
}else{
return $char_array;
}
$row["column_numbers"] = $char_array;
And I have also this message php : A PHP Error was encountered Severity: Notice Message: Array to string conversion
What am I do wrong? Thanks for help.
As hinted, string functions are sufficient here; specifically
substr()
andrtrim()
come handy:substr($col, -1)
gives us the last character andrtrim($col, '-')
helps to remove the last character.