473,569 Members | 2,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Grouping Arrays with same initial values

11 New Member
I have a new question about organizing multidimensiona l arrays.
I have an array containing several others; my aim is to obtain a new array, which groups together those arrays from the first array that share the same initial value ("00527-00527.tif" in this case).

Here's my code:

startingGroup = new Array(); //starting array
startingGroup[0] = ["00527-00527.tif;00527 ;Product_1;33;2 5,13"];
startingGroup[1] = ["00527-00527.tif;00528 ;Product_2;33;2 5,13"];
startingGroup[2] = ["01211-01211.tif;00119 ;Product_3;26;2 5,06"];

//I want to obtain this
resultingGroup = new Array(); //resulting array
resultingGroup[0] = ["00527-00527.tif;00527 ;Product_1;33;2 5,13","00527-00527.tif;00528 ;Product_2;33;2 5,13"];
resultingGroup[1] = ["01211-01211.tif;00119 ;Product_3;26;2 5,06"];[/HTML]

I wonder if is it possible to do it so

Any help would be mouch appreciated

Nov 16 '08 #1
1 1502
16,027 Recognized Expert Moderator MVP
You could use a temporary array to store the initial values. How would you determine an initial value? Is it till the semi-colon? Use a regular expression to test if the initial string matches.

Use concat() to combine arrays.
Nov 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: csx | last post by:
Hi everyone! two quick questions relating to arrays. Q1, Is it possible to re-assign array elements? int array = {{2,4}, {4,5}}; array = {2,3}
by: SABmore | last post by:
Is there a performance advantage to parsing thru a recordset verus using an array? I'm currently trying to populate a listbox by returning data from my database, then either parsing thru the recordset until I reach the EOF, or putting the data into an array. Thanks for your assistance.
by: Xiaozhu | last post by:
say, if you had parallel arrays containing the sales person id, the month, and the sales figures (for that person in that month), sorting on sales figure and preserve the order of figures within the data about the same person: Original Data: id month sales +-----+ +-----+ +-----+ | 432 | | 8 | | 89 | +-----+ ...
by: thehuby | last post by:
I have come across an issue using arrays ond objects; I am using an array to keep track of 'n' number of object(The code snippet below is from my initial testing) I first declare the object ($nr = new news_resource();), then call a function of the object ($nr->params_init(); ). This is the put into the first element of the db, I then call...
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have reports at the plan (overall totals), department and division levels which have sorting and grouping implemented with this new
by: Steve Kobes | last post by:
Is this legal? Must it print 4? int a = {{1, 2}, {3, 4}}, *b = a; printf("%d\n", *(b + 3)); --Steve
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in the hash are alphabetically sorted if the key happens to be alpha numeric. Which I believe makes sense because it allows for fast lookup of a key.
by: iamchiaweilin | last post by:
Hello all: What's the difference between p and q in the following statements? char p = "Hello"; char *q = "Hello"; I know q stores the address of 'H'. Question is: does p store the address of 'H' too?
by: mantrid | last post by:
I have records from a database that are extracted with php and displayed in a table. Data in some of the fields is replicated eg something1,item1,somethingelse1 something1,item1,somethingelse2 something1,item2,somethingelse3 something1,item2,somethingelse4 something2,item1,somethingelse5
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.