fork download
  1. <?php
  2.  
  3. $nomes = ["João", "Pedro", "Matheus"];
  4. $contagem = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
  5.  
  6. $a = [];
  7.  
  8. foreach($nomes as $nome) {
  9. $arrTemp = array_fill(0, count($contagem), $nome);
  10. $a = array_merge($a, $arrTemp);
  11. }
  12.  
  13. echo "Total: " . count($a);
  14. echo PHP_EOL;
Success #stdin #stdout 0s 82880KB
stdin
Standard input is empty
stdout
Total: 45
array(45) {
  [0]=>
  string(5) "João"
  [1]=>
  string(5) "João"
  [2]=>
  string(5) "João"
  [3]=>
  string(5) "João"
  [4]=>
  string(5) "João"
  [5]=>
  string(5) "João"
  [6]=>
  string(5) "João"
  [7]=>
  string(5) "João"
  [8]=>
  string(5) "João"
  [9]=>
  string(5) "João"
  [10]=>
  string(5) "João"
  [11]=>
  string(5) "João"
  [12]=>
  string(5) "João"
  [13]=>
  string(5) "João"
  [14]=>
  string(5) "João"
  [15]=>
  string(5) "Pedro"
  [16]=>
  string(5) "Pedro"
  [17]=>
  string(5) "Pedro"
  [18]=>
  string(5) "Pedro"
  [19]=>
  string(5) "Pedro"
  [20]=>
  string(5) "Pedro"
  [21]=>
  string(5) "Pedro"
  [22]=>
  string(5) "Pedro"
  [23]=>
  string(5) "Pedro"
  [24]=>
  string(5) "Pedro"
  [25]=>
  string(5) "Pedro"
  [26]=>
  string(5) "Pedro"
  [27]=>
  string(5) "Pedro"
  [28]=>
  string(5) "Pedro"
  [29]=>
  string(5) "Pedro"
  [30]=>
  string(7) "Matheus"
  [31]=>
  string(7) "Matheus"
  [32]=>
  string(7) "Matheus"
  [33]=>
  string(7) "Matheus"
  [34]=>
  string(7) "Matheus"
  [35]=>
  string(7) "Matheus"
  [36]=>
  string(7) "Matheus"
  [37]=>
  string(7) "Matheus"
  [38]=>
  string(7) "Matheus"
  [39]=>
  string(7) "Matheus"
  [40]=>
  string(7) "Matheus"
  [41]=>
  string(7) "Matheus"
  [42]=>
  string(7) "Matheus"
  [43]=>
  string(7) "Matheus"
  [44]=>
  string(7) "Matheus"
}