I have a form-is used so that the user can update its password:
Code:
 <label class="label" for="current">current</label><?php echo  $error ?> 
                          <input class="service" size="40"  type="text" name="current"><br>
                          <label class="label" for="new">New</label>
                          <input class="price" size="3"type="text" name="new"><br>
                          <label class="label" for="retyped">retyped</label>
                          <input class="price" size="3"type="text" name="retypednew"><br>
I have made a function where all the checks are made (no reason to show the code here)-the error messages are stored to an array and returned from the function:
Code:
if($new!=$retypednew)
         {$passerrors['notsame']='passwords do not much...';
         return $passerrors;
         }
Then I use a foreach loop to loop through the errors.
Code:
 foreach ($passerrors as $error) {
                      ?>  <label class="label" for="current">current</label>
                          <input class="service" size="40"  type="text" name="current"><br>
                          <label class="label" for="new">new</label>
                          <input class="price" size="3"type="text" name="new"><br>
                          <label class="label" for="retyped">retyped"</label>
                          <input class="price" size="3"type="text" name="retypednew"><br>
          
                          <?php  
                      }?>
What I want is that errors looped appear aside the input elements where a specific error appears
What code should a write(inside the one above) that for example the error that is related with the passwords not being the same appear aside the relevant input elements.

I have tried a lot various things but without success.