Questions tagged [arrays]

An array is an ordered 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 which is specific to a programming language, tag the question with the programming language being used.

Filter by
Sorted by
Tagged with
0
votes
0answers
3 views

A 'for each' PHP loop within an existing Array[]

I'm trying to loop an array from a database into an existing array. The two codes work well alone but I only get an error when trying to combine them.... for example... The current array (which is a ...
0
votes
0answers
9 views

Print different array into different column of excel

i want output like this but i am getting output like this const XlsxPopulate = require("xlsx-populate"); var data = { XYZ: [ { email: "[email protected]", office: "xyz.in", ...
0
votes
2answers
53 views

Only first element of the array is taken

i have searched of this issue on the internet but i dont find anything similar. i have an array in php. i passed this array to javascript function to check and disable checkboxes if their values are ...
1
vote
1answer
20 views

How to efficiently segment NumPy array by creating separate binary arrays

I'm trying to separate distinct objects in an image stored in the form of a NumPy array. For instance, if I have the 2D NumPy array: X = ([1.4E14, 1.4E14, 1.6E14], [1.4E14, 1.6E14, 1.6E14], [1.6E14, ...
0
votes
0answers
10 views

Instantly update frontend with uploaded image

I have an app that does direct messaging similar to instagram and others. Currently when a user enters text it immediately updates the UI. Where I'm having trouble is when a user attempts to send an ...
0
votes
1answer
22 views

Comparing data of payments

At my work we have two systems, one that collects the customers payments automatically every month. And one that manages the memberships of those customers. Sadly our outdated technology doesn’t ...
0
votes
0answers
9 views

how to change the size of a uiimageview appended to a empty array

My swift code uses a button to place imageviews on a uiviewcontroller that parent from a empty array. The problem is I dont know how to effect the size of the invidicual imageview after it is placed ...
-1
votes
0answers
17 views

Combining Arrays Using forEach Method Causing Errors

I'm using the eBay Api to update values for items i have stored in a database, which is shown with favorites array below. On my Favorites page, i'm displaying a user's favorite items. I also have ...
0
votes
2answers
28 views

Assigning value to function as object property within for loop

I am trying to create an array of objects. One object property is a function, which I want to change value of depending on which number in the array the object is. When I try to use the 'i' value ...
-5
votes
0answers
38 views

HW 10, Arrays, Java [closed]

This a homework problem and I could get answers from the lab but Im trying gain a concise understanding of how arrays actually work and Im hoping i can get that here. My professor has given me ...
1
vote
2answers
33 views

Golang best practices: empty array response or error?

What are best practices in terms of error handling for a function that accepts slice of objects and returns another slice of objects (ideally of same length as input array) along with error as follows:...
2
votes
1answer
31 views

trying to remove list element with index found in another function

Using the function searchAccount I found the index of a list element that I searched for using the user's input. I want to use that same index to pop the element from the list. This should be super ...
-1
votes
1answer
21 views

slicing 3 dimensional array in neural network python

In line X_train_1 = X_train[:,0:10081,:] in the model below, slicing seems to involve 3-dimensional data where the dataset is actually 921 x 10161. Can someone please explain how come we can do a 3-...
0
votes
0answers
22 views

C++ trouble flipping a ppm image

I successfully figured out how to read the rgb values from the ppm file and now i need to modify it. however when I flip the image (second set of for loops in readImg) it displays the exact same image....
0
votes
1answer
20 views

PHP Mysql while loop set default array value for empty row with limit

I have 2 groups of banner ads and 2 banner ads. The database is like this. groups_ads | id | name | max_places 1 group1 3 2 group2 2 banner_ads | id | group_id | ...
0
votes
2answers
23 views

PHP function to return array with repeated values

I have an array: Array ( [0] => Alex [1] => Michael [2] => Harry [3] => Dave [4] => Michael [5] => Victor [6] => Harry [7] => Alex [8] =>...
0
votes
0answers
19 views

Array class variable in Javascript classes (like in ruby classes?) [duplicate]

So in ruby, we can have a Class variable array to store all the instances of a class, like so class Car @@all = [] def initialize(model,make) @model = model @make = make @@all <...
0
votes
0answers
24 views

Undefined Behaviors: Exploring the stack address [C++] [duplicate]

I have an undefined behavior code as below: This code run unexpected int a; *(&a+1000) = 12; cout << *(&a+1000) << endl; The code that stated above doesn't allow me to point ...
0
votes
2answers
19 views

PHP array to count and return index of similar value

I have an array: Array ( [0] => Alex [1] => Michael [2] => Harry [3] => Dave [4] => Michael [5] => Victor [6] => Harry [7] => Alex [8] =>...
0
votes
0answers
16 views

How to add a setTimeout to a Random MP3 List

The following script works well on a web page to randomize the MP3s that play from the list below, but I would like the MP3s to start playing at about ten seconds later, after page load, with a ...
1
vote
6answers
41 views

Using array.map() to find elements from an array of objects

I have an array of objects and I'd like to return an array of all the ids. For example: const arr = [ {Locations:[{id:2129, Name: 'testAA'}, {id:3431, Name: 'testAB'}, {id:4373, Name: 'testAC'}]},...
0
votes
0answers
12 views

JavaScript program using arrays taking in user input and displaying various statistics

This program is suppose to take in input from the user for project name, cost, gain, and then the program should display the summary of each individual project along with its net profit, ROI, and ...
-4
votes
1answer
28 views

How can I check if an element in an array is equal to something in C? [closed]

My function is as follows: bool checkWin(spaceleft) { int i; int counter = 0; for(i=0;i<7;i++) { if(spaceLeft[i]==0) { counter++; } }...
0
votes
0answers
7 views

Error in pivot_table : Dropna=False : array is too big; `arr.size * arr.dtype.itemsize` is larger than the maximum possible size

Iam trying to run the following statement of pivot_table function of pandas. However, I want to retain NaN values for which I include "dropna=False" but the following error occurs : Statement : df=...
-8
votes
0answers
35 views

mountain like figure with ' * ' [closed]

I want to draw a mountain shape with c++. and i have no idea about algorithm. The code should get a number between 1 to 20 . let's call the number "num" then you should get numbers as many as "num"...
3
votes
4answers
46 views

How to remove all combination with the same element in subarray from array?

I have this array [[1,2,3],[4,1,6],[1,3,2],[1,2,4],[3,1,2],[4,6,1],[9,9,9]] and I want a function that do this: [[1,2,3],[4,1,6],[1,2,4],[9,9,9]]. This function removes all subarray with the ...
-2
votes
0answers
41 views

Could JavaScript for loops be asynchronous?

Say I have an array of numbers I want to iterate. In this array I do not care about the order in which expressions are finished, Only that the expressions are expressed. (As in number the number 4 ...
0
votes
0answers
17 views

is this a good way to save data from foreach to variables [duplicate]

and if you run the code below it functions normally but if I run the code on my computer / localhost I don't display output and there are no error messages` $data1 = "smith"; $data = [ [ ...
2
votes
3answers
27 views

Update an specific value inside the state with the reducer

I'm trying to update an specific value (in this case a comment inside a list) inside an array of objects that is inside the state. In this case the comment inside the msgs key. const list = [{ ...
0
votes
2answers
37 views

c++ reverse Array elements using dynamic Allocation Operators

Hi i'm the beginner of c++. This time, I try to reverse Array 's element-order using dynamic Allocation Operator. For example an array{1,2,3,4} will be rearranged {4,3,2,1} through calling function '...
0
votes
5answers
56 views

C# Read and split from .txt to struct array

I'm trying to make a basic login for my console app. I store the user data in a .txt file like this: ID;Name;IsAdmin. The txt has several lines. In the app I want to store user data in a struct User ...
0
votes
1answer
22 views

Evaluate whether an array contains an element other than given elements

I am trying to determine if my given array _servicetype contains an element other than 12,1,2,3. Below is what I have so far, Scenario 1: if my array is {1,2,3,6015} I want FALSE Scenario 2: if my ...
0
votes
1answer
24 views

How do you use a JSON array in a “WHERE IN” clause in MariaDB

I am using MariaDB version 10.2 I have an array of GUIDs stored as JSON in a table and I want to select rows from another table where the ID matches any of the GUIDs in the JSON array. group_table: ...
-1
votes
0answers
27 views

edit external php file containing arrays [closed]

I have a file where i store an array used in other pages. I call this page prijzen.php. In this file I store an array like this: Prijzen.php $behandeling1titel = "Gezichtsbehandelingen"; $...
-1
votes
1answer
37 views

How do you move an object from one array to array via feature? [closed]

I am trying to move an object from one array to another. Think of it like adding / moving a friend from non-friend to friend. I have two arrays, which can be seen below, and I am trying to move an ...
0
votes
0answers
43 views

Separate/Group plain text with Regex and PHP

I can separate data from the plain text below with Regex. Plain text: 190.A 42-year-old male patient has been delivered to a hospital in a grave condition with dyspnea, cough with expectoration of ...
0
votes
1answer
15 views

How do I query Firestore Array Value?

How can I Query the Array dates with the month value? String monthString = "12"; Query queryZero = db.collection("Users").document(mCurrentUser).collection("Dates").whereArrayContainsAny("dates", ???)...
2
votes
2answers
35 views

Fourier Transform with array

I'm trying to define a Fourier Transform for an array in Python. The formula I'm trying to use. However, the output is always an empty array. Could you help me fix my error ? import numpy as np def ...
2
votes
3answers
42 views

How do I insert HTML tags inside a Javascript array that contains pictures?

I've been trying to make a simple array slideshow with pictures and text and I'm super bad at JavaScript. At the moment I have this piece of code which is a slideshow with pictures (without the text): ...
-2
votes
2answers
39 views

Combining Array of Objects with another Object of Arrays After Component Mounts in React

I'm using eBay Api to update values for items i have stored in a database. On my Favorites page, i'm displaying a user's favorite items. I have the user's saved favorites which are loaded when the ...
0
votes
2answers
29 views

Make comparison between 3 numbers in array

I'm trying to make comprasion between 3 numbers in array. I'm gonna give code so you understand me exactly what i mean: $array = ["rank1"=>10,"rank2"=>20,"rank3"=>30]; $number = 3 So if $...
0
votes
0answers
17 views

K-means cluster algorithm not coverging

I would like to perform a k-means clustering algorithm for images from 0-9 (I want 10 clusters). I am doing the following: 1. Choosing an image at random and making it the center of cluster 1, k1, and ...
2
votes
3answers
29 views

Delete the previous and next element from an array while using array.map() in javascript

How can I delete the previous and next element from an array while using array.map(); In the code below, when I get to 'crossover' I want to delete both 'SUV' and 'sedan'. The following code ...
1
vote
2answers
38 views

Storing strings in stack vs code section in C?

I'm currently in a C class, and am very confused as to where string literals are stored. I understand that a string is just an array of chars, so something like char c[5] = {'A','B','C','D', 0}; is ...
0
votes
3answers
40 views

Compiler shows the error message “makes pointer from integer without cast” (reversing an array). How do i resolve this? [closed]

The code goes as follows. while calling the function reverse_array, How do I define the first function argument as an array? #include <stdio.h> void swap(int* a, int* b); void reverse_array(...
1
vote
2answers
35 views

How to update array from method using abstraction

My goal is to create an atm program using Java techniques like encapsulation, inheritance, polymorphism and what i use is the last, abstraction. When I enter a value on the withdraw or deposit value, ...
0
votes
0answers
24 views

['0','0','0','1']==['0','0','0','1'] evaluates to false [duplicate]

I have been making a brute-force 4-digit code breaker, but have run into some issues. After some debugging, I found out that ['0','0','0','1']==['0','0','0','1'] evaluates to false for some reason. ...
1
vote
4answers
104 views

How to return an array from a function in c++

Hello I am attempting to get data from an input file and have that placed in an array. I was able to complete my one function and have the array return as shown below: string * animal_name_grab() { ...
0
votes
1answer
46 views

Why in assigning a char array elements in c++, the assigned character is destroyed?

I wrote a function in C++ which removes two characters from a char array. I think when I assign str[o+2] to str[o], the str[o+2] shoud not be changed. But when I use cout to print it, I see that str[o+...
0
votes
1answer
33 views

How could we add arrays numbers shifted‽‽‽ In Java

I am training with the following programming exercise: Adding values of arrays in a shifted way. The statement is the following: Adding values of arrays in a shifted way You have to write a ...