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.
Related Topics
Lazarus: Program without GUI - Many WSRegister Errors
Question | 6 Answers
PHP: Remove all empty elements from string array
Tip | 0 Comments
JavaScript: Create and Use Arrays
Info | 0 Comments
Send Form Input as an Array to PHP Script
Tip | 0 Comments
Lazarus: Load File as Byte Array and save Byte Array as File
Tutorial | 0 Comments
PHP: Write array to individual Variables
Tutorial | 0 Comments
XAMPP: How to set up SSL/HTTPS for local Projects
Tutorial | 4 Comments
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.
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