<?php function bytes_to_int($size) { var_dump($size); // Remove the non-unit characters from the size. $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-numeric characters from the size. $size = preg_replace('/[^0-9\.]/', '', $size); if ($unit) { var_dump(round($size * pow(1024, stripos('bkmgtpezy', $unit[0])))); } else { var_dump(round($size)); } print "\n\n"; } bytes_to_int('12,2'); bytes_to_int('12,2 b'); bytes_to_int(''); bytes_to_int('m');
You have javascript disabled. You will not be able to edit any code.