Y
Y
yellow_pus2022-03-28 23:32:40
PHP
yellow_pus, 2022-03-28 23:32:40

How to generate random numbers and a letter, but in a certain range?

How can a faker generate a certain set of letters and numbers, but in a certain order? For example, I want to have a string in this format

*рандомные 2 буквы от A до G* *рандомные цифры от 1 до 9* *рандомные 2 буквы от G до Z*
.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2022-03-29
@yellow_pus

<?php
$str = ""
    .range("A", "G")[array_rand(range("A", "G"))]
    .range("A", "G")[array_rand(range("A", "G"))]
    .mt_rand(1, 9)
    .range("G", "Z")[array_rand(range("G", "Z"))]
    .range("G", "Z")[array_rand(range("G", "Z"))];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question