How to add a function with generator so that it selects certain strings php

I have a function with string output that outputs a sign in line 5. How to using a generator to add a function that will output line-by-line data from the first variable, where a new line is defined by sign; and the function should also have a limit – stop execution after output of 25 lines

<?php
function getRandomWord($len = 5) {
    $word = array_merge(range('a', 'z'), range('A', 'Z'));
    shuffle($word);
    return substr(implode($word), 0, $len);
}

$sign = ';';

for ($i = 0; $i < 100; $i++) {
    echo getRandomWord();
    if (($i + 1) % 5 == 0) {
        echo $sign;
    }
    echo "n";
}
?>