Why does this very simple array iteration not work?
I have the following array
Array ( [0] => Please enter address line 1
开发者_JS百科 [1] => Please tell us your first name
[2] => Please tell us your last name
[3] => Please tell us your email
[4] => You must tell us one phone number
[5] => Please tell us second applicants title
[6] => Please tell us second applicants first name
[7] => Please tell us second applicants last name )
I am looping through it as follows
foreach($error_hash as $value)
{
echo "error <li> $value <li/>";
}
Annoyingly I keep picking up blank lines
Any input would be great
Embed 'error' within the 'li' tags, so it won't produce extra output. Something like:
echo "<li> error, $value </li>";
Watch your tag
<li/>
Maybe this will help:
</li>
:)
I have checked. This is work.
$a[0] = 'Please enter address line 1';
$a[1] = 'Please tell us your first name';
foreach ($a as $b) {
echo $b;
}
精彩评论