Community discussions

MikroTik App
 
apipu
just joined
Topic Author
Posts: 1
Joined: Thu Nov 25, 2021 2:33 pm

How to convert "rate" at simple queue using mikrotik API in PHP

Thu Nov 25, 2021 2:54 pm

Hello, I'm connecting to the Mikrotik API in PHP, and when I get the rates they are in bytes format, so how do I convert them to MB or GB and so on..
I use the format bytes ($bytes / 1000) it can't be done because the rate has pair values, so how to change it?
<td><?php echo formatBytes($rate,2);?> </td>
here is code fo format bytes :
function formatBytes($bytes, $decimal = null)
 {
	$satuan = [' Bytes', ' KB', ' MB', ' GB', ' TB'];
	$i = 0;
	while ($bytes > 1024){
	$bytes /= 1024;
	$i++;
	}
	return round($bytes, $decimal). '' . $satuan[$i];
}
The eror says : Notice: A non well formed numeric value encountered

Who is online

Users browsing this forum: Google [Bot], marcelofares and 15 guests