fork download
  1. <?php
  2.  
  3. $feat = ['featured', 'featured', 'featured'];
  4. $no_feat = ['brrh', 'brrh', 'brrh', 'brrh','brrh', 'brrh', 'brrh', 'brrh', 'brrh', 'brrh', 'brrh', 'brrh', 'brrh', 'brrh', 'brrh', 'brrh'];
  5. $all = [];
  6. $all_len = count($feat) + count($no_feat);
  7. for($i = 0; $i < $all_len; $i++) {
  8. if($i%5 == 0 && count($feat) > 0) {
  9. $all[] = array_shift($feat);
  10. continue;
  11. }
  12. if(count($no_feat) > 0) {
  13. $all[] = array_shift($no_feat);
  14. }
  15. else {
  16. $all[] = array_shift($feat);
  17. }
  18. }
  19.  
  20. print_r($all);
Success #stdin #stdout 0.02s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => featured
    [1] => brrh
    [2] => brrh
    [3] => brrh
    [4] => brrh
    [5] => featured
    [6] => brrh
    [7] => brrh
    [8] => brrh
    [9] => brrh
    [10] => featured
    [11] => brrh
    [12] => brrh
    [13] => brrh
    [14] => brrh
    [15] => brrh
    [16] => brrh
    [17] => brrh
    [18] => brrh
)