Try开发者_如何学运维ing 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";
echo implode(", ", $array) . " has been entered";
uh, echo $array[$x];
?
??
how about
echo $array[$x]." 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];
}
}
After your updated comment:
You can use something like
foreach ($array as $a) {
echo $a;
}
echo "has been entered";
Use single-quotes rather than double-quotes:
echo implode(', ', $array) . ' has been entered';
精彩评论