convert bytes to kilobytes in php code example
Example: convert gb to bytes php
<?php
function tobytes($size, $type)
{
$types = array("B", "KB", "MB", "GB", "TB", "PB"); //You can add the rest if needed..
if($key = array_search($type, $types))
return $size * pow(1024, $key);
else return "invalid type";
}
echo tobytes(15, "MB"); //15728640
echo tobytes(2, "KB"); //2048
echo tobytes(3, "w/e"); //invalid type
?>