0

I have simple codes down below :

   $i = 0;    
    $array = array('name','email','address');

    while ($array[$i]) {
    echo "$array[$i]<br>";

    $i++;
    }

My problem : After echoing name, email, address without problem, It generates an error message "Undefined offset: 3". What is I insist to use WHILE loop instead of IF condition. How to deal with the error. Thank you

Lion Gordon
  • 87
  • 1
  • 6

1 Answers1

0
<?php
$array = array('name','email','address');
for ($i=0; $i<sizeof($array);$i++) {
    echo "$array[$i]<br>";
}
?>
Rushil K. Pachchigar
  • 1,263
  • 2
  • 21
  • 40