All Questions

818
votes
23answers
1212415 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\...
552
votes
16answers
308717 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...
155
votes
14answers
391287 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...
1413
votes
22answers
630912 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?
233
votes
7answers
42657 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...
1355
votes
24answers
1486287 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...
413
votes
5answers
109233 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>...
33
votes
4answers
15040 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 ...
741
votes
34answers
420957 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?
-7
votes
2answers
31944 views

How to avoid ArrayIndexOutOfBoundsException or IndexOutOfBoundsException?

If your question is I am getting a java.lang.ArrayIndexOutOfBoundsException in my code and I do not understand why it is happening. What does it mean and how can I avoid it? This is meant to be th...

Previous Next