Questions tagged [arrays]

An array is an ordered data structure consisting of a collection of elements (values or variables), each identified by one or multiple indexes. When asking about specific variants of arrays, use these related tags instead: [vector], [arraylist], [matrix]. When using this tag, in a question which is ...

1
vote
0answers
24 views

Spring Boot - JSON Object Array to Java Array

I have an endpoint in spring boot that consumes this JSON as an example: { "userId": 3, "postBody": "This is the body of a post", "postTitle": "This is the title of a post", "created":...
1
vote
1answer
23 views

Char pointers in C and multiple references to same address

Having worked with python before, I am having trouble understanding char pointers. #include <stdio.h> // 1 main() // 2 { // 3 char *...
-3
votes
2answers
30 views

two Array equal to each other by the index “Java ”

sorry i dont know how to explain my problem but here what im stuck with : so i have 2 array one is empName and other one is empPos i have in the empName the employs names and there positions is in ...
0
votes
0answers
18 views

How do I replace an external javascript array on the Vue js array?

I'm still a beginner in Vue.js and I have a problem. I have this code: data: function(){ return { search: '', zenes: [ { id: '1', name: 'Jhon Snow', profile_pic: '...
0
votes
0answers
22 views

What type of sorting algorithm resembles the most to this code? (if any).

I am learning programming (with Javascript) and as a test I decided to find a way to wrote an algorithm to sort and array of strings, this is what I came up with. // test of a sorting algorithm var ...
-1
votes
1answer
23 views

array value is identical to string value but the program ignores it

so below in the image you will see that the userInput value is inv523. this is identical to the tempArray[0] value (it is also equal to inv523, but was imported from a file and stored in the tempArray[...
0
votes
4answers
40 views

Java storing the inputs from scanner

When I can't use the 'list', but need to store the inputs from the scanner, how can I deal with it? I want to make the program counting the frequencies of the inputs appearing in the inputs from ...
0
votes
2answers
33 views

Shuffle a specific number of strings in a String Array in Java

I have a long textfile and I need to shuffle all the words which are longer than 4 letters but the other words need to remain in the same place. This without using the Collections module. I can ...
0
votes
0answers
13 views

PHP Form Input Array with NULLs [duplicate]

Using PHP Version 7.1.9, MariaDB 10.1.26. I'm submitting an array of form data to a MySQL database. The inputs look like this; // I have removed additional html form code for brevity <input type="...
0
votes
0answers
8 views

PHP Form Input Array with NULLs [duplicate]

Using PHP Version 7.1.9, MariaDB 10.1.26. I'm submitting an array of form data to a MySQL database. The inputs look like this; // I have removed additional html form code for brevity <input type="...
0
votes
0answers
7 views

PHP Form Input Array with NULLs [duplicate]

Using PHP Version 7.1.9, MariaDB 10.1.26. I'm submitting an array of form data to a MySQL database. The inputs look like this; // I have removed additional html form code for brevity <input type="...
1
vote
1answer
28 views

PHP Form Input Array with NULLs [duplicate]

Using PHP Version 7.1.9, MariaDB 10.1.26. I'm submitting an array of form data to a MySQL database. The inputs look like this; // I have removed additional html form code for brevity <input type="...
0
votes
3answers
46 views

Displaying the array contents by using ternary operators in C#

please could you explain me this fragment code? arr[i] + (i < arr.Length - 1 ? ", " : "") why it's "minus 1". Even if I'll put +1 or even +5 -whatever - the result is the same. How to read this ...
0
votes
1answer
29 views

Remove specific array element, not just last one with .pop - Redux-form

https://codesandbox.io/s/qzm5q6xvx4 I've created the above codesandbox. I am using redux-form ([https://redux-form.com]) that where you can add and remove fields to populate the form using .push and ...
0
votes
3answers
27 views

How to remove extra array level with nil value from a returned array

I have this code which is almost giving me what I want. def merge_data(keys, data) merged_data = keys.map {|hash| data.first.map {|k,v| if hash.values.first == k then hash.merge(v) end}} end ...
-3
votes
2answers
21 views

How to build till-end array sampler with numpy?

I have some np.array: >>> arr = np.arange(7) >>> arr array([0, 1, 2, 3, 4, 5, 6]) I want to get all splitting keys that have some minimum length of second part and lasts in the ...
0
votes
0answers
18 views

Powershell array for loops not working as intended [duplicate]

I have a script that reads multiple files's counts from present day and compares it to its count from the previous day. I have the code working as it should, but since there is multiple process files ...
0
votes
1answer
17 views

How to get attributes for tags as key and value from xml using php

I have to convert array to xml using php. Below is my xml, <custom-attributes> <custom-attribute dt:dt="int" name="Attr_New">0</custom-attribute> <custom-attribute dt:dt="...
0
votes
0answers
6 views

I have 2 different types of array and unable to find the difference

This is my first array : [ 'full_name' =>'Mukesh' ,'username' => 'mukesh@123' ] This is my second array Array ( [full_name] => mukesh [username] => mukesh@123) My second array i got ...
0
votes
1answer
30 views

Assigning onClick button to the proper feature. Map function ReactJS

I created this mockup and I am trying to put this into real life component mockup I started from something simple so I created 3 buttons and an array but what happens is that when I click on any ...
0
votes
3answers
51 views

PHP - Check if any nested array is not empty

If i have a nested array as follows, how can I check if any of the dates arrays are NOT empty? $myArray = [ '1' => [ 'dates' => []], '2' => [ 'dates' => []], '3' => [...
2
votes
5answers
36 views

How to parse true and false strings in an array to become booleans

How can I parse the true and false strings in an array to become boolean in Javascript? For instance, from: {"id":1,"dashboardId":1,"w":2,"h":2,"x":0,"y":0,"i":"n0","minW":1,"minH":1,"maxH":1000,"...
2
votes
4answers
54 views

How to remove array from an array in javascript (Angular6)?

I have this array var a = [[1,3][2,3],[3,4],[6,7]]; var b =[[1,3],[2,3]]; I want to remove b array from a. I tried it var arr = [[1,3],[2,3]]; var b = [1,3]; var arr = arr.filter((el)=> !b....
0
votes
2answers
31 views

TableViewCell deleted then All checkmarks disappear on swift

I searched the web for my problem but nothing helped in my case. It's kind of special. My App has a checklist feature, everything is working fine but there is this problem. When adding a checkmark on ...
0
votes
1answer
9 views

Selection Sort for strings and integers at the same time

Here is the task I have been set with: Create a text file named Names_ages.txt with the following content: Jones 14 Abrams 15 Smith 19 Jones 9 Alexander 22 Smith 20 Smith 17 Tippurt 42 Jones 2 ...
0
votes
0answers
27 views

Vue app, Javascript, conditionally adding an Object to an array

I have a restaurant menu which is an array of objects each of which has the following properties:- name id - the id is autogenerated quantity options - which itself is an array that has two value ...
2
votes
2answers
40 views

Array > Object: how to index an array of objects with reduce, omitting the index from nested element in result (es2017)?

I have an array like this: const peopleArray = [ { "id": "Antoine", "country": "France" }, { "id": "Alejandro", "country": "Spain" } ] That I would ...
2
votes
1answer
26 views

Save a sliced numpy matrix into another numpy array

Well, this is a very quick question. I want to slice an array (numpy array), and save it in another array (define it in another numpy array). I used the following codes which is wrong. I'd be happy if ...
3
votes
1answer
41 views

Array of objects to objects with properties as keys

I need some help to get objects from an array of object with keys coming from nested properties of the objects in the initial array. This is the initial array : [ { "id":{ "...
0
votes
0answers
16 views

XML to JSON XSLT

I am facing issue with my xslt code which was written for converting xml to json file. The issue is that this XSLT is not recognizing array objects as for some xml files, that segment may come only ...
0
votes
1answer
37 views

Error java.lang.ArrayIndexOutOfBoundsException [duplicate]

I looked over on stackoverflow but I still can't figure what's wrong with the code. PS: I am a beginner /****************************************************************/ class Main { public ...
0
votes
2answers
20 views

Two arrays one with time in, another with time out of something

Lets say we have 2 arrays, one of them (i.e. A) contains the time an object i will come into a room, and the other (i.e. B) contains the time i will leave. Neither of these are in any way sorted and ...
-2
votes
3answers
48 views

How to get all elements from this array with ruby?

Want to get all the unique ids from this type of array: [[], [1], [2], [1, 3, 2], [4, 5, 6, 7, 8, 1], [2, 4], [3], [2]]
-1
votes
2answers
27 views

Are these logical operators?

JavaScript: //variable to hold total price of shopping cart var cart_total_price=0; //iterate over array of objects for(var product in shoppingCart){ //add new ...
-2
votes
3answers
36 views

.join ( ) Only Works in console.log ( )

When I use the console.log( ) function to join this array it returns the combined array, but when I use the .join( ) function outside of console.log( ), it does not combine the array. How do I combine ...
1
vote
1answer
59 views

Segmentation fault - reading array of initialized pointers

could you help me with little problem? I have following class; class Link { private: Demand *demand_[NUMBER_OF_CORES][NUMBER_OF_SLICES]; public: Link() { for (int i = 0; i <...
0
votes
0answers
9 views

Accessing Variables

i'm very beginner to php and I want to get CurrencyCode and Value in to two variables from the below example. any idea how I can do this? Thanx $results = $soapClient->CalculateRate($params); ...
-1
votes
0answers
15 views

Filter column in a PySpark data frame based on content of the previous rows

I have a data frame in PySpark sorted by freq column in descending order like this: +----+---------------+ |freq| items| +----+---------------+ | 4| [E, A, D, C]| | 3| [E, A, C]| |...
0
votes
1answer
27 views

How to add validation custom messages with array items rules when validating array in Laravel?

I've custom validation code: $this->validate($request, [ 'array' => 'required|array|max:100', 'array.*' => 'required|string|distinct|min:3' ], [ 'array.max' => 'Array can't ...
0
votes
4answers
34 views

how to add dimensions to a numpy element?

i have a numpy.array like this [[1,2,3] [4,5,6] [7,8,9]] How can i change it to this:- [[[1,0], [2,0], [3,0]] [[4,0], [5,0], [6,0]] [[7,0], [8,0], [9,0]]] Thanks in advance.
0
votes
1answer
48 views

setState doesn't set values

We got a ReactJS frontend delivered for our school project. We have to make a Laravel backend for it. I'm using an API to fetch the dashboard layout from the database. The current frontend makes use ...
4
votes
4answers
53 views

Sort/group array by key

TL;DR Sort/group array by key without adding another level to the array (data parsed by jQuery plugin)? Details I am building an array to return to some <select> DOM element. It takes in CC (...
0
votes
1answer
26 views

Comparing exact values in two arrays

So this is a bit confusing. I am currently making a Top-Trumps game. Right now I have two arrays, a player deck and a computer deck. The way it works is that it creates an array from a text file of ...
0
votes
1answer
19 views

Get array of dates given 2 dates using MomentJs in ReactJs

Currently i'm importing Moment and Moment range as below, Need the array of dates between given 2 dates so that dates can be iterated import Moment from 'moment'; import {extendMoment} from 'moment-...
0
votes
0answers
8 views

how to get values from two array inside main array php

I have main Array called data contain 3 array every array contain more than one array like this 0 => array:2 [ 0 => array:5 [ "name" => "user1" "description" => "user ...
-1
votes
5answers
51 views

Why does this result in an ArrayIndexOutOfBoundsException at run-time?

This is the code: public class Test { public static void main(String[] args) { int[] a= new int[3]; System.out.print(a[a.length]); } } Why does this result in an ...
1
vote
1answer
21 views

Excel formula: counting array elements with a criteria

I have an array, which is the result of the multiplication of two COUNTIF functions. The result is {0,2,7,4,0}. I want to count the number of non-zero elements. I tried the following: =COUNTIF(...
-1
votes
3answers
50 views

Automatically add links to strings of keywords

In my article, I want to automatically add links to keywords. My keywords array: $keywords = [ 0=>['id'=>1,'slug'=>'getName','url'=>'https://www.getname.com'], 1=>['id'=&...
-1
votes
1answer
25 views

Converting nested objects in PHP to an array [duplicate]

I've recently ran into an issue where I had to convert an object that functions as a model (enforcing datatypes and such) into an array for further processing. At least the public and private ...
0
votes
0answers
36 views

Array Of Array in ionic (Angular) [on hold]

Im building an Ionic app, this app call an API, the response they send me is an array of object and I change the response in an array of array As you can see I have an array of array But in my ...