0

I write PHP code to extract from Linux 'top' the server idle value and I store it in $idle. If I echo the value using php I receive this e.g.

98.5

which is correct . If I save $idle in a file in this way

file_put_contents("/usr/local/st/file, "$idle",FILE_APPEND);      

and then I open the /usr/local/st/file with an editor like nano I see this

[0;10m [39;49m [1m98.5 [0;10m [39;49

as can you see it contains 98.5 but it has also a lot of undesirable chars. How to avoid it ?

gr68
  • 420
  • 1
  • 10
  • 25
  • 2
    Please try https://stackoverflow.com/questions/40731273/php-remove-terminal-codes-from-string and https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python – Wiktor Stribiżew Apr 24 '20 at 10:26
  • this worked https://stackoverflow.com/questions/40731273/php-remove-terminal-codes-from-string , thank you. – gr68 Apr 24 '20 at 10:33

0 Answers0