3v4l.org

run code in 300+ PHP versions simultaneously
<?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((float) $size)); } print "\n\n"; } bytes_to_int('12,2'); bytes_to_int('12,2 b'); bytes_to_int(''); bytes_to_int('m');
Output for git.master, git.master_jit, rfc.property-hooks
string(4) "12,2" float(122) string(6) "12,2 b" float(122) string(0) "" float(0) string(1) "m" Fatal error: Uncaught TypeError: Unsupported operand types: string * int in /in/F83lJ:11 Stack trace: #0 /in/F83lJ(22): bytes_to_int('') #1 {main} thrown in /in/F83lJ on line 11
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
173.04 ms | 406 KiB | 5 Q