开发者

Why does this very simple array iteration not work?

开发者 https://www.devze.com 2023-01-11 21:38 出处:网络
I have the following array Array ( [0] => Please enter address line 1 开发者_JS百科 [1] => Please tell us your first name

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

  • Please enter address line 1
  • error
  • Please tell us your first name
  • error
  • ect .......
  • 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;
    }
    
    0

    精彩评论

    暂无评论...
    验证码 换一张
    取 消