473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Multi Array?


Hi,

I'm not sure how to do this. Let's say I have an array that looks
like this:

$timing[$x] = array('Count' =0);

So, basically I've initialized that element of the array with another
array item, that being 'Count'. Later, I want to add another item to
the array, like this:

$timing[$x] = array('Start' =date ("g:i:s"));

How would I do that? I'm sure I cannot use the 'array' function more
than once........do I need to define it and initialize it with nulls?

Along those same lines, can I do something like this: $timing[$x]
['Count']++;

I'm looking for examples, but not finding any on the web. If someone
can help, I'd really appreciate it.

Thank you,

John
Jun 2 '08 #1
8 1314
Mtek wrote:
Hi,

I'm not sure how to do this. Let's say I have an array that looks
like this:

$timing[$x] = array('Count' =0);

So, basically I've initialized that element of the array with another
array item, that being 'Count'. Later, I want to add another item to
the array, like this:

$timing[$x] = array('Start' =date ("g:i:s"));

How would I do that? I'm sure I cannot use the 'array' function more
than once........do I need to define it and initialize it with nulls?

Along those same lines, can I do something like this: $timing[$x]
['Count']++;

I'm looking for examples, but not finding any on the web. If someone
can help, I'd really appreciate it.

Thank you,

John

This works:

$timing[$x]['Count'] = 0;
$timing[$x]['Start'] = date("g:i:s");

$timing[$x]['Count']++;

echo var_dump($timing);
--
Norman
Registered Linux user #461062
Jun 2 '08 #2
On May 26, 4:22*pm, Norman Peelman <npeel...@cfl.rr.comwrote:
Mtek wrote:
Hi,
I'm not sure how to do this. *Let's say I have an array that looks
like this:
$timing[$x] = array('Count' *=0);
So, basically I've initialized that element of the array with another
array item, that being 'Count'. *Later, I want to add another item to
the array, like this:
$timing[$x] = array('Start' *=date ("g:i:s"));
How would I do that? *I'm sure I cannot use the 'array' function more
than once........do I need to define it and initialize it with nulls?
Along those same lines, can I do something like this: *$timing[$x]
['Count']++;
I'm looking for examples, but not finding any on the web. *If someone
can help, I'd really appreciate it.
Thank you,
John

This works:

$timing[$x]['Count'] = 0;
$timing[$x]['Start'] = date("g:i:s");

$timing[$x]['Count']++;

echo var_dump($timing);

--
Norman
Registered Linux user #461062- Hide quoted text -

- Show quoted text -

What is the difference between that and something like this:

$tables[$x] = array('Acronym' =$table_data[0],
'List' =$table_data[1],
'Name' =$table_data[2]);
I'm really looking for a sturcture like this.......is there any
difference at all???
Jun 2 '08 #3
On May 26, 4:22*pm, Norman Peelman <npeel...@cfl.rr.comwrote:
Mtek wrote:
Hi,
I'm not sure how to do this. *Let's say I have an array that looks
like this:
$timing[$x] = array('Count' *=0);
So, basically I've initialized that element of the array with another
array item, that being 'Count'. *Later, I want to add another item to
the array, like this:
$timing[$x] = array('Start' *=date ("g:i:s"));
How would I do that? *I'm sure I cannot use the 'array' function more
than once........do I need to define it and initialize it with nulls?
Along those same lines, can I do something like this: *$timing[$x]
['Count']++;
I'm looking for examples, but not finding any on the web. *If someone
can help, I'd really appreciate it.
Thank you,
John

This works:

$timing[$x]['Count'] = 0;
$timing[$x]['Start'] = date("g:i:s");

$timing[$x]['Count']++;

echo var_dump($timing);

--
Norman
Registered Linux user #461062- Hide quoted text -

- Show quoted text -

What is the difference between that and something like this:
$tables[$x] = array('Acronym' =$table_data[0],
'List' =$table_data[1],
'Name' =$table_data[2]);
I'm really looking for a sturcture like this.......is there any
difference at all???

What about this?

$summary[$x]['seating'] = array('Seating' =$row[0],
'Count' =$row[1]);

Is the word 'seating' like a section title or something?

John
Jun 2 '08 #4
Mtek wrote:
On May 26, 4:22 pm, Norman Peelman <npeel...@cfl.rr.comwrote:
>Mtek wrote:
>>Hi,
I'm not sure how to do this. Let's say I have an array that looks
like this:
$timing[$x] = array('Count' =0);
So, basically I've initialized that element of the array with another
array item, that being 'Count'. Later, I want to add another item to
the array, like this:
$timing[$x] = array('Start' =date ("g:i:s"));
How would I do that? I'm sure I cannot use the 'array' function more
than once........do I need to define it and initialize it with nulls?
Along those same lines, can I do something like this: $timing[$x]
['Count']++;
I'm looking for examples, but not finding any on the web. If someone
can help, I'd really appreciate it.
Thank you,
John
This works:

$timing[$x]['Count'] = 0;
$timing[$x]['Start'] = date("g:i:s");

$timing[$x]['Count']++;

echo var_dump($timing);

--
Norman
Registered Linux user #461062- Hide quoted text -

- Show quoted text -


What is the difference between that and something like this:
$tables[$x] = array('Acronym' =$table_data[0],
'List' =$table_data[1],
'Name' =$table_data[2]);
I'm really looking for a sturcture like this.......is there any
difference at all???

What about this?

$summary[$x]['seating'] = array('Seating' =$row[0],
'Count' =$row[1]);

Is the word 'seating' like a section title or something?

John

$tables[$x] = array();

indicates $tables[$x] is an array itself.

$tables[$x] = array('Acronym' =$table_data[0],
'List' =$table_data[1],
'Name' =$table_data[2]);

Is just a shortcut method of initializing the array. The result is
exactly the same as:

$tables[$x] = array();
$tables[$x]['Acronym'] = $table_data[0];
$tables[$x]['List'] = $table_data[1];
$tables[$x]['Name'] = $table_data[2];

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 2 '08 #5
Mtek wrote:
On May 26, 4:22 pm, Norman Peelman <npeel...@cfl.rr.comwrote:
>Mtek wrote:
>>Hi,
I'm not sure how to do this. Let's say I have an array that looks
like this:
$timing[$x] = array('Count' =0);
So, basically I've initialized that element of the array with another
array item, that being 'Count'. Later, I want to add another item to
the array, like this:
$timing[$x] = array('Start' =date ("g:i:s"));
How would I do that? I'm sure I cannot use the 'array' function more
than once........do I need to define it and initialize it with nulls?
Along those same lines, can I do something like this: $timing[$x]
['Count']++;
I'm looking for examples, but not finding any on the web. If someone
can help, I'd really appreciate it.
Thank you,
John
This works:

$timing[$x]['Count'] = 0;
$timing[$x]['Start'] = date("g:i:s");

$timing[$x]['Count']++;

echo var_dump($timing);

--
Norman
Registered Linux user #461062- Hide quoted text -

- Show quoted text -


What is the difference between that and something like this:
$tables[$x] = array('Acronym' =$table_data[0],
'List' =$table_data[1],
'Name' =$table_data[2]);
I'm really looking for a sturcture like this.......is there any
difference at all???
Same thing, I just didn't use the 'array' object to create them.
What about this?

$summary[$x]['seating'] = array('Seating' =$row[0],
'Count' =$row[1]);

Is the word 'seating' like a section title or something?

John

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Jun 2 '08 #6
On May 26, 7:01*pm, Norman Peelman <npeel...@cfl.rr.comwrote:
Mtek wrote:
On May 26, 4:22 pm, Norman Peelman <npeel...@cfl.rr.comwrote:
Mtek wrote:
Hi,
I'm not sure how to do this. *Let's say I have an array that looks
like this:
$timing[$x] = array('Count' *=0);
So, basically I've initialized that element of the array with another
array item, that being 'Count'. *Later, I want to add another item to
the array, like this:
$timing[$x] = array('Start' *=date ("g:i:s"));
How would I do that? *I'm sure I cannot use the 'array' function more
than once........do I need to define it and initialize it with nulls?
Along those same lines, can I do something like this: *$timing[$x]
['Count']++;
I'm looking for examples, but not finding any on the web. *If someone
can help, I'd really appreciate it.
Thank you,
John
This works:
$timing[$x]['Count'] = 0;
$timing[$x]['Start'] = date("g:i:s");
$timing[$x]['Count']++;
echo var_dump($timing);
--
Norman
Registered Linux user #461062- Hide quoted text -
- Show quoted text -
What is the difference between that and something like this:
* $tables[$x] = array('Acronym' =$table_data[0],
* * * * * * * * * * * 'List' * *=$table_data[1],
* * * * * * * * * * * 'Name' * *=$table_data[2]);
I'm really looking for a sturcture like this.......is there any
difference at all???

Same thing, I just didn't use the 'array' object to create them.
What about this?
* * * $summary[$x]['seating'] = array('Seating' =$row[0],
* * * * * * * * * * * * * * * * * * * 'Count' * =$row[1]);
Is the word 'seating' like a section title or something?
John

--
Norman
Registered Linux user #461062
-Have you been towww.php.netyet?-- Hide quoted text -

- Show quoted text -

So, I'm still a bit unclear what the 'seating' represents.......

Jun 2 '08 #7
Mtek wrote:
On May 26, 7:01 pm, Norman Peelman <npeel...@cfl.rr.comwrote:
>Mtek wrote:
>>On May 26, 4:22 pm, Norman Peelman <npeel...@cfl.rr.comwrote:
Mtek wrote:
Hi,
I'm not sure how to do this. Let's say I have an array that looks
like this:
$timing[$x] = array('Count' =0);
So, basically I've initialized that element of the array with another
array item, that being 'Count'. Later, I want to add another item to
the array, like this:
$timing[$x] = array('Start' =date ("g:i:s"));
How would I do that? I'm sure I cannot use the 'array' function more
than once........do I need to define it and initialize it with nulls?
Along those same lines, can I do something like this: $timing[$x]
['Count']++;
I'm looking for examples, but not finding any on the web. If someone
can help, I'd really appreciate it.
Thank you,
John
This works:
$timing[$x]['Count'] = 0;
$timing[$x]['Start'] = date("g:i:s");
$timing[$x]['Count']++;
echo var_dump($timing);
--
Norman
Registered Linux user #461062- Hide quoted text -
- Show quoted text -
What is the difference between that and something like this:
$tables[$x] = array('Acronym' =$table_data[0],
'List' =$table_data[1],
'Name' =$table_data[2]);
I'm really looking for a sturcture like this.......is there any
difference at all???
Same thing, I just didn't use the 'array' object to create them.
>>What about this?
$summary[$x]['seating'] = array('Seating' =$row[0],
'Count' =$row[1]);
Is the word 'seating' like a section title or something?
John
--
Norman
Registered Linux user #461062
-Have you been towww.php.netyet?-- Hide quoted text -

- Show quoted text -


So, I'm still a bit unclear what the 'seating' represents.......
It's simply an array index. Nothing more, nothing less.

$summary[$x]['seating'] is an array element; this element in turn is
another array.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 2 '08 #8
On May 26, 8:19*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Mtek wrote:
On May 26, 7:01 pm, Norman Peelman <npeel...@cfl.rr.comwrote:
Mtek wrote:
On May 26, 4:22 pm, Norman Peelman <npeel...@cfl.rr.comwrote:
Mtek wrote:
Hi,
I'm not sure how to do this. *Let's say I have an array that looks
like this:
$timing[$x] = array('Count' *=0);
So, basically I've initialized that element of the array with another
array item, that being 'Count'. *Later, I want to add another itemto
the array, like this:
$timing[$x] = array('Start' *=date ("g:i:s"));
How would I do that? *I'm sure I cannot use the 'array' function more
than once........do I need to define it and initialize it with nulls?
Along those same lines, can I do something like this: *$timing[$x]
['Count']++;
I'm looking for examples, but not finding any on the web. *If someone
can help, I'd really appreciate it.
Thank you,
John
This works:
$timing[$x]['Count'] = 0;
$timing[$x]['Start'] = date("g:i:s");
$timing[$x]['Count']++;
echo var_dump($timing);
--
Norman
Registered Linux user #461062- Hide quoted text -
- Show quoted text -
What is the difference between that and something like this:
* $tables[$x] = array('Acronym' =$table_data[0],
* * * * * * * * * * * 'List' * *=$table_data[1],
* * * * * * * * * * * 'Name' * *=$table_data[2]);
I'm really looking for a sturcture like this.......is there any
difference at all???
Same thing, I just didn't use the 'array' object to create them.
>What about this?
* * * $summary[$x]['seating'] = array('Seating' =$row[0],
* * * * * * * * * * * * * * * * * * * 'Count' * =$row[1]);
Is the word 'seating' like a section title or something?
John
--
Norman
Registered Linux user #461062
-Have you been towww.php.netyet?--Hide quoted text -
- Show quoted text -
So, I'm still a bit unclear what the 'seating' represents.......

It's simply an array index. *Nothing more, nothing less.

$summary[$x]['seating'] is an array element; this element in turn is
another array.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Seems like a good way to organize things.......

Thanks for the explanation......
Jun 2 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Eclectic | last post by:
Hey all, I have been using usort to sort my multi dimensional arrays ... function cmp($a, $b){ if($a == $b){ return 0; } return ($a < $b) ? -1 : 1; }
2
by: iop | last post by:
Hello there, I'd like to "parse" an entire multi-dimension array like this : APP APP without knowing "framework" or "config" or anything passed as variables... 'cause it's simple to call...
2
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray =...
5
by: Cant Think Today | last post by:
I have multi-dimesional arrays that can be specifed by the user, e.g 1,2,3,4,5 1,2,3,4,5,6,7,8,9,10 1,2,3,4,5,6 I think a bit of code that will iterate over these arrays to print out the...
6
by: Adam Hartshorne | last post by:
The input to a function of a 3rd party library I want to use requires a double**, which is a multi-dimension array of doubles. I have looked on the net etc and seen several ways of supposedly...
8
by: masood.iqbal | last post by:
All this time I was under the illusion that I understand the concept of multi-dimensional arrays well ---- however the following code snippet belies my understanding. I had assumed all along...
0
by: Kirk Marple | last post by:
an external API that we're using is giving me back video data in a multi-dimensional Array (not byte, just System.Array). so, for an HD quality video, the data is organized as of bytes. i know...
4
by: Robert P. | last post by:
I can easily store a one-dimensional array in viewstate ( see Test1 ) If I try storing a multi-dimensional array in the viewstate it's crapping out on me when it goes to serialize the array (not...
4
by: Balaskas Evaggelos | last post by:
Hi, does anyone know how i can sort a multi-dimensional array by a specific field ? for example i want to sort arr where n=2, but i need the data of every array to follow that order. ...
4
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post by:
Hi, consider the attached code. Serializing the multi-dimensional array takes about 36s vs. 0.36s for the single-dimensional array. Initializing the multi-dimensional array takes about 4s...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.