This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Astra_Memory_Limit_Notice::format_bytes( int $bytes )

Format bytes to human readable format


Description


Parameters

$bytes

(int) (Required) Number of bytes to format.


Return

(string) Formatted bytes string.


Source

File: inc/class-astra-memory-limit-notice.php

	private function format_bytes( $bytes ) {
		$units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
		$total = count( $units );

		for ( $i = 0; $bytes > 1024 && $i < $total - 1; $i++ ) {
			$bytes /= 1024;
		}

		return round( $bytes, 2 ) . ' ' . $units[ $i ];
	}


User Contributed Notes

You must log in before being able to contribute a note or feedback.