note 116204 deleted from function.number-format by cmb

From: Date: Sun, 13 Jan 2019 10:47:36 +0000
Subject: note 116204 deleted from function.number-format by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210059@lists.php.net to get a copy of this message
Note Submitter: qrworld.net ---- Here a function to get de size of a file in a human way using the function number_format: function convertFileSize($file, $size=null, $decimals=2, $dec_sep='.', $thousands_sep=','){ if (!is_file($file)){ return "El fichero no existe"; } $bytes = filesize($file); $sizes = 'BKMGTP'; if (isset($size)){ $factor = strpos($sizes, $size[0]); if ($factor===false){ return "El tamaño debe ser B, K, M, G, T o P"; } } else { $factor = floor((strlen($bytes) - 1) / 3); $size = $sizes[$factor]; } return number_format($bytes / pow(1024, $factor), $decimals, $dec_sep, $thousands_sep).' '.$size; } Source: http://softontherocks.blogspot.com/2014/11/obtener-el-tamano-de-un-fichero-y.html

« previous php.notes (#210059) next »