3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Tasodifiy kod generatsiya qiluvchi funksiya function generateFormattedCode() { // Harflar va raqamlar to'plami $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); // Format: CUBE-XXXX-XXXX-XXXX-XXXX $format = 'CUBE-XXXX-XXXX-XXXX-XXXX'; $formattedCode = ''; // Format bo'yicha kod yaratish for ($i = 0; $i < strlen($format); $i++) { if ($format[$i] === 'X') { $formattedCode .= $characters[rand(0, $charactersLength - 1)]; } else { $formattedCode .= $format[$i]; } } return $formattedCode; } // Bir necha o'yin kodi generatsiya qilish function generateMultipleCodes($count) { $codes = []; // $count miqdorida kod yaratish for ($i = 0; $i < $count; $i++) { $codes[] = generateFormattedCode(); } return $codes; } // 10 ta kod generatsiya qilish $gameCodes = generateMultipleCodes(4); // Natijani ko'rsatish foreach ($gameCodes as $code) { echo $code . PHP_EOL; } ?>

preferences:
30.21 ms | 404 KiB | 5 Q