I have an array of strings and I am trying to implement a foreach to echo each of the strings like the following:
$options = array('string1', 'string2', 'string3', 'string4', 'string5');
foreach ($options as $option)
{
echo $option;
}
I’ve also tried
foreach (options as $key => $option)
Any help is appreciated!
Of course you can – see other answers. I just want to add this consideration:
If you also need the index (variabile
$iwill be “binded” to the index, starting from zero):