All Questions

839
votes
23answers
1235774 views

PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"

I am running a PHP script, and keep getting errors like: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php on line 10 Notice: Undefined index: my_index C:\wamp\www\...
566
votes
16answers
318382 views

Access / process (nested) objects, arrays or JSON

I have a (nested) data structure containing objects and arrays. How can I extract the information, i.e. access a specific or multiple values (or keys)? For example: var data = { code: 42, it...
163
votes
15answers
400361 views

What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?

What does ArrayIndexOutOfBoundsException mean and how do I get rid of it? Here is a code sample that triggers the exception: String[] name = {"tom", "dick", "harry"}; for(int i = 0; i<=name.leng...
1428
votes
24answers
640352 views

Why is using "for...in" with array iteration a bad idea?

I've been told not to use for...in with arrays in JavaScript. Why not?
235
votes
7answers
43466 views

How can I sort arrays and data in PHP?

Due to the enormous and ever repeating amount of "How do I sort my unique snowflake of an array?" questions, this is a reference collection of basic sorting methods in PHP. Please close any questio...
1380
votes
25answers
1512251 views

What's the simplest way to print a Java array?

In Java, arrays don't override toString(), so if you try to print one directly, you get the className + @ + the hex of the hashCode of the array, as defined by Object.toString(): int[] intArray = new...
416
votes
5answers
109926 views

How do I use arrays in C++?

C++ inherited arrays from C where they are used virtually everywhere. C++ provides abstractions that are easier to use and less error-prone (std::vector<T> since C++98 and std::array<T, n>...
35
votes
4answers
16219 views

How can I access an array/object?

I have the following array and when I do print_r(array_values($get_user));, I get: Array ( [0] => 10499478683521864 [1] => 07/22/1983 [2] => email@saya.com ...
761
votes
35answers
430909 views

How to randomize (shuffle) a JavaScript array?

I have an array like this: var arr1 = ["a", "b", "c", "d"]; How can I randomize / shuffle it?
249
votes
7answers
32550 views

What is array decaying?

What is decaying of an array? Is there any relation to array pointers?

Previous Next