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'];
  5. $all = [];
  6. $h = 0;
  7. $all_len = count($feat) + count($no_feat);
  8. for($i = 0; $i < $all_len; $i++) {
  9. if($i%5 == 0 && count($feat) > 0) {
  10. $all[] = array_shift($feat);
  11. $h++;
  12. continue;
  13. }
  14. if(count($no_feat) > 0) {
  15. $all['no_feat' .$h][] = array_shift($no_feat);
  16. }
  17. else {
  18. $all[] = array_shift($feat);
  19. }
  20. }
  21. print_r($all);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => featured
    [no_feat1] => Array
        (
            [0] => brrh
            [1] => brrh
            [2] => brrh
            [3] => brrh
        )

    [1] => featured
    [no_feat2] => Array
        (
            [0] => brrh
            [1] => brrh
            [2] => brrh
            [3] => brrh
        )

    [2] => featured
    [no_feat3] => Array
        (
            [0] => brrh
            [1] => brrh
            [2] => brrh
            [3] => brrh
        )

)