1 2 3 4 5 6 |
<?php $names = array('mike','bob','barry'); echo implode(',', $names) ; ?> |
When adding to an array it places the word AND inside, (this is hidden) so when you use the ‘[ ]’ brackets you can implode the array with the code below, instead of ‘echo $conditions[0]’ and incrementing by one to see all of them….handy!
So below will output ‘Mike AND Bob AND Barry’
1 2 3 4 5 6 7 8 |
<?php $conditions[] = 'Mike'; $conditions[] = 'Bob'; $conditions[] = 'Barry'; echo implode(' AND ', $conditions); ?> |