Questions tagged [arrays]

An array is an ordered linear data structure consisting of a collection of elements (values, variables, or references), each identified by one or more indexes. When asking about specific variants of arrays, use these related tags instead: [vector], [arraylist], [matrix]. When using this tag, in a question that is specific to a programming language, tag the question with the programming language being used.

arrays
Filter by
Sorted by
Tagged with
0 votes
3 answers
1k views

PHP Create Sub Arrays from Master Array based on keys

This pertains to PHP. I have an array of arrays that is a recordset from a db query: Array ( [0] => Array ( [0] => Amazon [1] => AmazonSendTracking ...
Yourguide's user avatar
  • 109
0 votes
1 answer
242 views

Get first array in object with length X

I am importing an excel file into a web app using xlsx library and each row in the excel sheet is stored into an object containing arrays with length equal to the number of cells in each row as shown ...
Banani720's user avatar
  • 159
1 vote
1 answer
51 views

Count Unique Values with Conditions Excel

I'm trying to create a simple chart to show how many employees are on a given corrective action level within a specified date range. The issue I'm running into is this: The log shows associate Test 1 ...
Newbie's user avatar
  • 55
-1 votes
2 answers
139 views

Is it possible to declare an array using a variable?

Hi I was told during my first class about arrays in C that you cannot declare them using a variable, for example: int array[n]. Yet if I write a code like this: #include <stdio.h> int main() { ...
Pietro Alessandrini's user avatar
1 vote
3 answers
68 views

Looping through Array or Object to update counts

I have a problem that is similar to the following: let fruits = { Apples:0, Bananas:0, Oranges:0 } var basket = ['Apples', 'Oranges', 'Bananas', 'Potatoes', 'Cucumber'] Objective: to update the ...
Adnan's user avatar
  • 3,269
0 votes
1 answer
531 views

Multi Level JSON Filter

So I have this json: this.state = { projects: [{ id: 10, name: "Project 10", runTimes: [{ id: 186, name: "Do Homeworks", start: "2020-W01", end: "2020-W09", ...
Sander Cokart's user avatar
0 votes
2 answers
80 views

Array of hashes, how to count the list of 'webpages' with most unique 'page' views?

I am trying to display the most unique page views in order, but am unsure how. i have the variable with data: data = [{"help_page/1"=>"126.318.035.038"}, {"contact"=>"184.123.665.067"}, {"...
ARTLoe's user avatar
  • 1,781
0 votes
4 answers
5k views

How to compare two 2d lists in python element wise?

I have two 2d lists: Both are of same size with size unknown (different for different set of lists) For instance: A = [['ID', 'Name', 'Profession'], [1, 'Tom', 'Teacher'], [2, 'Dick', 'Actor'], [3, '...
Thoufeeque's user avatar
-1 votes
5 answers
2k views

JavaScript function to check equality of two arrays

I'm tasked with writing a function that takes two 1-dimensional arrays of simple values (no objects, etc), and returns true only if they are equal. The function also must use the Array.forEach() ...
will-t-harris's user avatar
1 vote
1 answer
75 views

Cant access fetched elements of an array [duplicate]

i want to sort fetched data via estimated population values. But when i fetch the data and map the names and numbers objects to a new array, i can't even access a single object in the array. Already ...
franklin's user avatar
0 votes
1 answer
418 views

Why can't I change elements in this array

In Unity I create five lists of bools and put them in a jagged array as shown below (in my gamecontrol script). I initialize the 5 List in the inspector in unity, so no initialization is needed in ...
Doruk Okbay's user avatar
1 vote
1 answer
1k views

React hooks object update gets strange behaviour on Safari browser

React hooks object update gets strange behaviour on Safari browser(only on Safari browser) const [state, setState] = React.useState({ show_welcome: true, show_inline: false, restriction: false, ...
Mo.'s user avatar
  • 26.9k
0 votes
4 answers
83 views

How to add objects to array?

I am trying to add objects formatted as {title: value} to an array. I wrote the following function const newResults = resultData.map(result => { let results = []; if (result.INTELLCONT....
Brock's user avatar
  • 125
0 votes
2 answers
2k views

C# Winforms - bind textbox to array element from class

I'm currently trying to bind an array element from a class to a text box without success. class Test{ ... string[] toto = new string[]{"element1"}; } Test test; void form_load() { test = ...
Mathias Osterhagen's user avatar
-2 votes
1 answer
41 views

Iterating via given array or range of this array when nested for-loop takes place

I am new to python so far and have encountered while trying to loop via nested for loop in for loop: def find_it(seq): count = 0 for i in seq: for j in seq: ...
yose93's user avatar
  • 55
-1 votes
1 answer
39 views

Array-declaration issue in Python [duplicate]

I have trouble declaring a two-dimensional list in Python. Below are two different matrices; A and R. When changing the content of a single cell I am successful in the R-matrix, but not so much in the ...
Enthuziast's user avatar
  • 1,195
2 votes
5 answers
826 views

JavaScript shortest way to map an array of objects to a new array of new objects?

I have an array of person objects, where each person have an array of profiles objects which consist of name and an image url, and a list of addresses objects which consist of lat and long properties, ...
Alex's user avatar
  • 2,032
0 votes
1 answer
87 views

Check if there is a value from a string in the array, if not, then add it

So, I have a lot of string that look like: !,3,1,10,27,13,078,43,05,31,307,48,16,24,042,43,02,10,267,43 !,3,2,10,26,03,031,36,07,75,215,51,09,57,121,53,30,40,234,50 !,3,3,10,23,29,117,46,04,36,114,46 ...
Someone's user avatar
0 votes
2 answers
27 views

Array parsing and converting to new array List

How to convert below array to specific output? Input: [ { "id": "9664581", "isSelected": true, "isExpanded": false, "disabled": false, "cells": [ { "id": "9664581:...
user1394497's user avatar
-1 votes
1 answer
76 views

php create arrays dynamically and merge

I'm trying to create an unknown number of arrays dynamically inside a foreach loop, merge them all at the end into one array, and use this in a JSON format for Google Analytics. So far I have the ...
Aaron's user avatar
  • 63
0 votes
2 answers
397 views

Node.js, map through array of objects, and put specific values into a new array

I'm trying to go through the ratings array for each object, extract the scores for each inner object and add them into a new array. For example, the post with post_id: "5e1223c2383ce049d8b32eb5", I ...
CodingNoob's user avatar
0 votes
1 answer
77 views

Array to function pointer in C. How do I select which element I want from the array using enums?

I want the user to enter a value liked ADD or SUB to perform the desired operation but I'm getting "array subscript is not a integer instead". I know I can enter digits instead like 0, 1 , 2 etc. ...
JerSci's user avatar
  • 177
0 votes
2 answers
50 views

How can I separate from and to dates from dates array?

I have an array, which has only one month dates. $dates =array ( '2018-10-15', '2018-10-16', '2018-10-17', '2018-10-13', '2018-10-19', ...
Imran Abbas's user avatar
0 votes
0 answers
788 views

Python convert defaultdict(lambda: defaultdict(dict)) to numpy array

I have these two dictionaries: alpha[worker] = {'A3M34FQ1OVNWPG': 1, 'AZH91RXTSG1NZ': 1, 'AHJGJ2J15SEHY': 1, 'A2IR6T0Y2MSDYD': 1, 'AGV7F8F0IV2MY': 1} beta[example] = {'107_1108_0': 1, '953_1938_1': 1,...
joasa's user avatar
  • 976
0 votes
1 answer
21 views

Altering Data format of Array and Removing Key/Value Pairs [duplicate]

I am pulling some email addresses data from our db to print to a file in our Node project. That code looks like this: const sql = `${query}`; let emailRecords = await this.mariaDB.query(sql); ...
Rey's user avatar
  • 1,413
0 votes
0 answers
41 views

How do I trace an exact or find a specific value in a matplotlib graph?

The code below plots a 2d axis graph. How can I find a specific point on the graph?Specifically the x value when y= -0.99. Apologies for the simple question as I'm new to this and am not sure how to ...
nailclipper's user avatar
1 vote
1 answer
147 views

Swift 5 How to get JSON multilayer data to append?

Please Help me, I am trying to get an array inside an array. Apply it to custom table view with headers and sections, headers is the first array, sections is the second. I added a comment in the line:...
Hussam Dabaan's user avatar
-2 votes
1 answer
75 views

Umarshalling JSON results in empty struct [duplicate]

I have the following JSON structure: dataJson := `{"data1" : [["a",1]["b",2]], "data2": ["a","b",3]}` And want to unmarshal it with Go. I am trying the following code: type myData struct { row ...
jsor's user avatar
  • 97
-1 votes
3 answers
100 views

Grouping items in an array

I require some assistance on how to transform an array with multiple objects where I want to group some of the types into one object. Specifically the ones with type "H*" and "text". So far I have ...
Aleksandr's user avatar
2 votes
3 answers
84 views

Unexpected results while passing arrays as parameters in C?

I am trying to get used to using pointers but i am struggling a bit whilde passing them into functions as parameters. I read that arrays are passed by reference to functions therefore a code like this ...
Mustafa Çığ Gökpınar's user avatar
2 votes
4 answers
759 views

Is it okay to exit a loop when an exception is thrown?

I solved a task on Hackerrank.com, where the problem was like this: You have an Array. This Array contains numbers. Now you enter two numbers: The first one describes a sum The second ...
DudeWhoWantsToLearn's user avatar
0 votes
1 answer
120 views

How to Compare between 2D String Array elements to find the repeated elements?

So, I have this coursework where we've been asked to find the repeated words in a string and display the repeated words and how many times they're repeated. I had the idea of extracting the words and ...
CCody's user avatar
  • 3
3 votes
1 answer
2k views

Android Firebase : Update/Add record in Nested Array data

I am stuck in one case of firebase operation in android. My Requirement : I have table Named : "Values" This value table contains following type of data. { "menu": [ { ...
Topsy's user avatar
  • 177
1 vote
1 answer
80 views

Argument of type 'X' is not assignable to parameter of type 'Y'

I have created those types: export type Optional<T> = T | null; and I have this function updateBook( book: Array<Optional<Hostel>>) that I call with let book: Hostel | null [] =...
Sandro Rey's user avatar
  • 2,769
0 votes
4 answers
527 views

How to pass coordinates data from a class to another class in React

I want to pass coordinates from a class to another one. I am retrieving coordinates from an api. The code looks like the following: import React, { Component } from 'react'; class Test3 ...
K.V.'s user avatar
  • 51
0 votes
0 answers
44 views

add an array to an array using arrayName[]= add_array without the index 0 in php [duplicate]

how can I add this array $triggers = [ SMS_INVOICE => [ 'id' => 1, 'name' => 'Invoice Overdue Notice', 'info' => 'Trigger when invoice ...
Douglas Okolaa's user avatar
2 votes
2 answers
1k views

How to compare and filter only unmatched arrays from two array of objects in es6

In my Angular Application, I'm trying to get only the updated array which was modified from UI. Here, I have two array where one of the role_name is changed. I wanted to compare and filter out the ...
UI_Dev's user avatar
  • 3,377
0 votes
0 answers
202 views

C++ 2D array index compare

I need help in a C++ for a school task. I don't really know where the error is. It seems like it skips the first row. I should compare the highest value with an other row's avarage value. Task: In ...
Melkor's user avatar
  • 1
-2 votes
1 answer
57 views

Convert two array in one multidimensional [duplicate]

I have two array : a = [a,b,c,d] b = [1,2,3,4] And I would like to convert in this c = [[a,1], [b,2],[c,3],[d,4]] I tried a << b but this does not work, any idea how to convert this ?
Dam76's user avatar
  • 15
0 votes
3 answers
108 views

remove custom object from array php

I have a table with Gift Cards 1,2,3 .... 100 $ Gift card user tel me I want 123$ I tell him based on his request, which card he must use I have this array Array ( [0] => Array ( [...
RedHat5's user avatar
  • 30
-1 votes
1 answer
326 views

How to request an array to http get parameters with a for?

Below is my code to your view: import warnings import contextlib import json import requests from urllib3.exceptions import InsecureRequestWarning old_merge_environment_settings = requests.Session....
Matheus Cabral's user avatar
-1 votes
1 answer
20 views

Access member of a JSON string array [closed]

I have the following JSON string and for example I need to access a single element of the array. Let's say I just wanted to pull out "host2." I keep trying things like members[1] but that doesn't work....
Jimmy D's user avatar
  • 5,303
0 votes
1 answer
79 views

Converting array into 2D array within loop

I have a loop which defines arrays with changing variables - start row and row numbers always changing. I would need to be able to access certain columns within this array, but I have no idea how to ...
Vidomina Sangre's user avatar
2 votes
4 answers
72 views

Javascript Array - checking for matching item across 2 arrays

I have 2 arrays of string objects. let count = 0; var basket1 = [‘Apples’, ‘Cucumber’, ‘Lettuce’, ‘Bananas’, ‘Pears’, ‘Cauliflower’, ‘Strawberry’] var basket2 = [‘Apples’, ‘Bananas’, ‘Oranges’, ‘...
Adnan's user avatar
  • 3,269
3 votes
4 answers
6k views

Vending Machine function in Javascript

I'm very new to Javascript: I've been working with it for a few weeks casually now. This is my first post, so I apologize if I'm not thorough enough, but I think I have been below! I want to create a ...
PhilosophOtter's user avatar
0 votes
3 answers
71 views

Access array within Javascript object

I have an http request that calls an api and returns something that looks like this in the body. I need to access the "members" array. body.results is undefined. What am I doing wrong? The call to ...
Jimmy D's user avatar
  • 5,303
0 votes
1 answer
24 views

I cannot set while to work properly in for loops in ts

I want to get array of arrays with unique values, but at some point while gets missed or ignored (I presume because of the asynchronous nature of it). Can someone help with a adding a promise to ...
QuestionOne's user avatar
0 votes
5 answers
94 views

How to merge the array elements in between?

I have these arrays for my navbar. $all_pages = array( 'home' => 'Home', 'about' => 'About us', 'gallery' => array( 'photo-gallery' => 'Photo Gallery', ...
Vigneshwaran's user avatar
0 votes
5 answers
112 views

Replace data from Array based on the Id

I have an array : mainArray = [ {name : "Eminem", id : 2}, {name : "Rakim" , id : 3 }, {name : "Kuniva", id : 4 } ] Suppose I edit the name "Kuniva" and replace it with "Proof" and send the it to ...
MenimE's user avatar
  • 284
-4 votes
4 answers
47 views

javascript - add object at the beginning on each map iteration

So, let's suppose I have this: var officers = [ { id: 20, name: 'Captain', lastName: 'Piett' }, { id: 24, name: 'General', lastName: 'Veers' }, { id: 56, name: 'Admiral', lastName: 'Ozzel' }, ...
manuel.menendez's user avatar