Tag: arrays

62 votes
6 answers
1.3K views
Preserving order with LINQ

I use LINQ to Objects instructions on an ordered array. Which operations shouldn't I do to be sure the o

avatar
Keila
0 1 0 9
asked 07 September, 2021
59 votes
30 answers
1.1K 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 + &

avatar
Jeff
0 1 0 9
asked 07 September, 2021
65 votes
28 answers
2.1K views
How do I declare and initialize an array in Java?

How do I declare and initialize an array in Java?

avatar
Wilfredo
0 1 0 9
asked 07 September, 2021
54 votes
29 answers
2.9K views
How do I determine whether an array contains a particular value in Java?

I have a String[] with values like so: public static final String[] VALUES = new String[] {"AB","BC","CD","AE

avatar
Suzan
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
342 views
Create ArrayList from array

I have an array that is initialized like: Element[] array = {new Element(1), new Element(2), new Element(3)};

avatar
Margo
0 1 0 9
asked 07 September, 2021
57 votes
11 answers
774 views
the best way to make codeigniter website multi-language. calling from lang arrays depends on lang session?

I'm researching hours and hours, but I could not find any clear, efficient way to make it :/ I have a co

avatar
Solomon
0 1 0 9
asked 07 September, 2021
50 votes
30 answers
592 views
50 votes
30 answers
1.9K views
How can I check if an object is an array?

I'm trying to write a function that either accepts a list of strings, or a single string. If it's a

avatar
Trudy
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
598 views
Sort array of objects by string property value

I have an array of JavaScript objects: var objs = [ { first_nom: 'Lazslo', last_nom: 'Jam

avatar
Daniel
0 1 0 9
asked 07 September, 2021
59 votes
25 answers
3K views
Checking if a key exists in a JavaScript object?

How do I check if a particular key exists in a JavaScript object or array? If a key doesn't exist, and I

avatar
Yolando
0 1 0 9
asked 07 September, 2021
56 votes
20 answers
1.7K views
How to insert an item into an array at a specific index (JavaScript)

I am looking for a JavaScript array insert method, in the style of: arr.insert(index, item) Preferably in jQu

avatar
Arline
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
409 views
Loop through an array in JavaScript

In Java you can use a for loop to traverse objects in an array as follows: String[] myStringArray = {"Hello",

avatar
Charis
0 1 0 9
asked 07 September, 2021
48 votes
30 answers
2K views
How do I check if an array includes a value in JavaScript?

What is the most concise and efficient way to find out if a JavaScript array contains a value? This is the onl

avatar
Omar
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
954 views
For-each over an array in JavaScript

How can I loop through all the entries in an array using JavaScript? I thought it was something like this: f

avatar
Cortez
0 1 0 9
asked 07 September, 2021
54 votes
30 answers
2.5K views
How can I remove a specific item from an array?

I have an array of numbers and I'm using the .push() method to add elements to it. Is there a simple way

avatar
Luis
0 1 0 9
asked 07 September, 2021
63 votes
23 answers
2.8K views
Get first key in a (possibly) associative array?

What's the best way to determine the first key in a possibly associative array? My first thought it to ju

avatar
Thurman
0 1 0 9
asked 07 September, 2021
57 votes
30 answers
2.7K views
How to check if PHP array is associative or sequential?

PHP treats all arrays as associative, so there aren't any built in functions. Can anyone recommend a fair

avatar
Gigi
0 1 0 9
asked 07 September, 2021
64 votes
30 answers
2.5K views
Convert a PHP object to an associative array

I'm integrating an API to my website which works with data stored in objects while my code is written usi

avatar
Jeff
0 1 0 9
asked 07 September, 2021
52 votes
27 answers
774 views
Remove empty array elements

Some elements in my array are empty strings based on what the user has submitted. I need to remove those eleme

avatar
Lynette
0 1 0 9
asked 07 September, 2021
52 votes
20 answers
1.3K views
PHP array delete by value (not key)

I have a PHP array as follows: $messages = [312, 401, 1599, 3, ...]; I want to delete the element containin

avatar
Serina
0 1 0 9
asked 07 September, 2021