I have an array with a random number of words. It can contain a single word as a minimum or more than 10 words. Example:
$words = array (
0 => 'This',
1 => 'is',
2 => 'my',
3 => 'word'
)
Now, lets say i want to echo out 6 words from this array, starting over when we reach the end of the array. I want the logic to be something like this
for ($i=0; $i < 6 ; $i++) {
//if $words[$i] exist, print it, else reset the array and start over until we reach all 6
}
I'd like the result to be: "This is my word this is"
I struggle to figure out the maths for this. Any help would be much appreciated!
Thanks