note 128851 added to function.random-int

From: Date: Sat, 02 Sep 2023 12:51:07 +0000
Subject: note 128851 added to function.random-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-220812@lists.php.net to get a copy of this message
A small function for generating version 4 GUIDs. <?php function v4uuid() { $a = str_pad(dechex(random_int(0x0000_0000, 0xffff_ffff)), '0', STR_PAD_LEFT); $b = str_pad(dechex(random_int(0x0000, 0xffff)), '0', STR_PAD_LEFT); $c = dechex(random_int(0x4000, 0x4fff)); $d = dechex(random_int(0x8000, 0xbfff)); $e = str_pad(dechex(random_int(0x0000_0000_0000, 0xffff_ffff_ffff)), '0', STR_PAD_LEFT); return "$a-$b-$c-$d-$e"; } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 222.153.168.209) ---- Manual Page -- https://php.net/manual/en/function.random-int.php Edit -- https://main.php.net/note/edit/128851 Del: integrated -- https://main.php.net/note/delete/128851/integrated Del: useless -- https://main.php.net/note/delete/128851/useless Del: bad code -- https://main.php.net/note/delete/128851/bad+code Del: spam -- https://main.php.net/note/delete/128851/spam Del: non-english -- https://main.php.net/note/delete/128851/non-english Del: in docs -- https://main.php.net/note/delete/128851/in+docs Del: other reasons-- https://main.php.net/note/delete/128851 Reject -- https://main.php.net/note/reject/128851 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220812) next »