Trying to stop the words has been entered from repeating when the array displays its contents when echoed.
Here is the code.
echo "$array[$x] has been entered";
Trying to stop the words has been entered from repeating when the array displays its contents when echoed.
Here is the code.
echo "$array[$x] has been entered";
After your updated comment:
You can use something like
foreach ($array as $a) {
echo $a;
}
echo "has been entered";
As far as i could get your question; try below code:
foreach($array as $key => $value)
{
// if this is the first item
if ($key === 1)
{
echo "$array[$key] has been entered";
}
else
{
echo $array[$key];
}
}
Use single-quotes rather than double-quotes:
echo implode(', ', $array) . ' has been entered';