How to output a value on every third result of a foreach statement in php?

前端 未结 11 1956
醉话见心
醉话见心 2021-01-04 13:37

I have a foreach statement in my app that echos a list of my database results:



        
11条回答
  •  猫巷女王i
    2021-01-04 14:03

    If the $featured_projects array is based on incremental index you could simply use the index and the modulo % operator.

    Otherwise you would have to add a counter.

    http://php.net/manual/en/language.operators.arithmetic.php

提交回复
热议问题