PHP program to generate random phone number
Use accurate and meaningful names for functions and variable to improve readability.
Condense your numeric loop conditions into a for loop versus while loop.
Avoid declaring single-use variables.
Make functions versatile by passing output-altering arguments with the call.
Write default argument values when possible/reasonable so that, in some cases, no arguments need to be passed for the most common scenario.
Avoid counting a static array in a loop.  If you need to count it, count it once before entering the loop and reference the count variable.
If you prefer mt_rand's randomness, use it in place of my array_rand() call below, but obey #6 about counting.
Obey PSR Coding Standards.  Spacing and tabbing don't improve performance, but they sure make your code easier to read.


Some suggested applications of my generalized advice:

Code: (Demo)

function randomNumberSequence($requiredLength = 7, $highestDigit = 8) {
    $sequence = '';
    for ($i = 0; $i &lt; $requiredLength; ++$i) {
        $sequence .= mt_rand(0, $highestDigit);
    }
    return $sequence;
}

$numberPrefixes = ['0812', '0813', '0814', '0815', '0816', '0817', '0818', '0819', '0909', '0908'];
for ($i = 0; $i &lt; 21; ++$i) {
    echo $numberPrefixes[array_rand($numberPrefixes)] , randomNumberSequence() , "\n";
}


Possible Output:

08161776623
08157676208
08188430651
08187765326
08176077144
09087477073
08127415352
08191681262
08168828747
08195023836
08198008111
09096738254
08162004285
08166810731
08130133373
09093214002
08154125422
08160702315
08143817877
08194806336
08133183466