Functions
WebDev/*nix assorted functions & hacks
Search
find all
Array
-
Bash
-
Classes
-
Config
-
DateTime
-
Debug
-
dotjs
-
File
-
foooo
-
Git
-
HTML
-
Images
-
Javascript
-
Linux
-
Math
-
Misc
-
MySQL
-
OS X
-
Reading
-
Redis
-
Shell scripts
-
snippets
-
SQL
-
Strings
-
TextMate
-
Web
-
\(^o^)/ Fun!
-
_Misc hacks
-
_Pages
File
clean_filename($filename)
duplicate_name($name, etc)
fetch_dirlist($path='', $exts='')
file_ext($file)
file_label($file, $label)
fsize($x)
resize_image($image, $sizes)
7
found
auth
Name:
Category: File
Body:
// echo fsize(10000000); // 9.5 MB // echo fsize(123456); // 120.563 KB #__________________________ # fsize($x, $precision=3) / function fsize($x, $precision=3) { settype($x, 'integer'); $sizes = explode(' ', 'Bytes KB MB GB TB PB EB'); for ($i=0; $x>=1024; $i++) { $x /= 1024; } if ($sizes[$i] === 'MB') $precision = 1; return round($x, $precision) .' '. $sizes[$i]; } // see also str2bytes to turn 0.5 mb into 524288
Footer