Category "arrays"

MySQL Filter JSON_CONTAINS Any value from Array

I have a JSON field in a MySQL database that contains values like [1,3,4,7]. I would like to be able to easily supply another array from a PHP variable and det

Javascript - Generating all combinations of elements in a single array (in pairs)

I've seen several similar questions about how to generate all possible combinations of elements in an array. But I'm having a very hard time figuring out how to

Move a child array to parent array and change parent/child name

I know probably this was asked before not sure if was in this form but I did tried some replay from what I found here about this and failed. ok I have this arr

TypeScript enum to object array

I have an enum defined this way: export enum GoalProgressMeasurements { Percentage = 1, Numeric_Target = 2, Completed_Tasks = 3, Average_Milest

Solve almostIncreasingSequence (Codefights)

Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from th

PHP array sort and remove duplicates by two field values

I have an array structure like this [0]=>array(3) { ["Number"]=> "L1" ["Location"]=> "Location-A" ["Qty"]=>"1" } [1]=>array(3

List within single quotes [duplicate]

I have a list which is in single quotes. '[{"Name":"name1","value":"value1"},{"name":"name2","value":"value2"}]' I receive this as an input p

Finding union of 2 sorted arrays (with duplicates)

I'm trying to find the union of 2 sorted arrays (with duplicates) but I feel I'm not coming up with the most elegant code (what I have works btw, I just feel I

Decimal To Binary conversion using Array and Stack

This is the C Program I have written to convert a Decimal number to it's equivalent Binary number. I have used Stack (implemented using array) and the following

PhP how to calculate moments with variables rows

I have 45 - 50 array rowss that are deserialized json return values in standard PhP array string format, from cURL with data that looks like the following: Arr

javascript - schedule with tabs

I created I javascript schedule thermostat for a enteire week and work. But now I have some problems with tabs, because when I move a period, moving on slider,

Sum all odd indexes in an array

I have to complete a program according to these instructions: public class SumOddIndex { public static void main(String[] args){ int[] array = {1,1,

Sum all odd indexes in an array

I have to complete a program according to these instructions: public class SumOddIndex { public static void main(String[] args){ int[] array = {1,1,

Codewars Challenge - Count of positives / sum of negatives

My code works but it's not being accepted in order to pass the challenge. Any help on what I'm doing wrong would be appreciated. Challenge Description: Given

The ArraySort callback is not sorting my array in the correct order

Using ColdFusion to sort an multi-dimensional array based on a "Price per sq. ft" field from high to low. It has been in production and worked in testing, but

Return multiple values from a function using mysqli_fetch_assoc [closed]

How do I return multiple values from the array returned from mysqli_fetch_assoc() in the code below? function db_query($sql){

Javascript remove all occurrence of duplicate element, leaving the only one that is unique

I want to remove elements that occurr more than once and get the unique element. The array always has 3 elements. Lets say i have an array [2,3,2], then I need

Javascript. Reduce an array by adding only odd numbers. Javascript returns NaN when I use %2 on a number with if [duplicate]

I am trying to sum all odd numbers of an array. The following method does not work and returns NaN. Could someone explain me why? I found a wo

General approach to modifying an array while looping through it

Is it safe in Perl6 (as opposed to perl5 or other languages) to loop through an array while modifying it? For instance, if I have an array of websites to downlo

Given a sequence of integers, return the sum of all the integers that have an even index, multiplied by the integer at the last index

This is my solution and it passes some of the tests, but not all of them. Can anyone help me and explain why? Thank you :) function evenLast(numbers) { let su