00 Votes

undefined array key php

Question by Guest | 2022-07-30 at 18:25

<?php

$var = array(2,5);

$cnt = count($var);

for ($i = 0; $i < $cnt; $i++) {

echo $var[$i]."\n";

echo $var[$i+1]."\n";

}

?>

this code show error.

( ! ) Warning: Undefined array key 2 in C:\xampp\htdocs\CAYTASOURCE\snippets\q.php on line 7

I want to print the current and next value.

ReplyPositiveNegative
00 Votes

Why are you posting this another time when your original question is already answered?!

https://www.askingbox.com/question/print-current-and-next-value-of-array-undefined-array-key-error

This double post will be deleted soon.
2022-07-30 at 18:28

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.