<?php
$i = 0;
$array = array('name', 'email', 'address');
while ($array[$i]) {
echo "$array[$i]<br>";
$i++;
}
?>
PHP Notice: Undefined offset: 3 in /workspace/Main.php on line 6
<?php
$i = 0;
$array = array('name', 'email', 'address');
while ($array[$i]) {
echo "$array[$i]<br>";
$i++;
}
?>
PHP Notice: Undefined offset: 3 in /workspace/Main.php on line 6
In while loop until your array has value. use isset()
for it. change your while condition as below:
<?php
$i = 0;
$array = array('name', 'email', 'address');
while (isset($array[$i])) {
echo "$array[$i]<br>";
$i++;
}
?>