Hello
I have this
$data=“17.2-6.0-69.0”
which is extracted from a server log
When I save this $data in a file using
file_put_contents(“data”, "$data
",FILE_APPEND);
In my data file I have lines like these
^[0;10m^[39;49m^[0;10m17.2^[0;10m^[39;49m-^[0;10m^[39;49m^[0;10m6.0^[0;10m^[39;49m-^[0;10m^[39;49m^[0;10m69.0^[0;10m^[39;49m
? which could be the cause
Thank you
At a guess, I’d say this is a character encoding issue (these are commonly seen if you transfer between Linux and Windows systems).
Have a look into http://uk.php.net/mb_convert_encoding.
Still no solution , really lost.
Are the odd characters being introduced from the log read or the file_put_contents?
Have you checked that data doesn’t contain any hidden characters (which come from character encoding differences)? It looks to me like the characters you’re seeing (^[0;10m^[39;49m) represent whitespace in the string, but without having access to the specifics of your problem, such as server setup, log file type, …, I can’t help any further.
before executing this
file_put_contents(“data”, "$data
",FILE_APPEND);
I echo the data using this
echo “-$data-”;
and I receive this
-17.2-6.0-69.0-
which is correct .
If I save it on file , is all messed up .