3v4l.org

run code in 300+ PHP versions simultaneously
<?php function uuid($c = 4) { $x4 = function($c) { for ($n = ''; strlen($n) < $c + 1; $n = $n.mt_rand()); return substr($n, -$c); }; return sprintf( '%s-%04d-%04d-%04d-%04d%04d%04d', time(), $x($c), $x($c), $x($c), $x($c), $x($c), $x($c), $x($c) ); } echo uuid();

preferences:
24.67 ms | 407 KiB | 5 Q