tags:

views:

59

answers:

6

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";
A: 

uh, echo $array[$x];?

Kenaniah
A: 

??

how about

echo $array[$x]." has been entered";
Scott Evernden
A: 

After your updated comment:

You can use something like

foreach ($array as $a) {
  echo $a;
}

echo "has been entered";
Alec Smart
A: 

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];
  }
}
Sarfraz
+2  A: 
echo implode(", ", $array) . " has been entered";
Amarghosh
A: 

Use single-quotes rather than double-quotes:

echo implode(', ', $array) . ' has been entered';
hiddentao