Multi Array? | | | re: 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 | | |
Mtek wrote: Quote:
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 | | | | re: Multi Array?
On May 26, 8:19*pm, Jerry Stuckle <jstuck...@attglobal.netwrote: Quote:
Mtek wrote: Quote:
On May 26, 7:01 pm, Norman Peelman <npeel...@cfl.rr.comwrote: Quote:
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.
> Quote: Quote:
>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 -
> Quote: Quote:
- Show quoted text -
> Quote:
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...... | | | | re: Multi Array?
On May 26, 7:01*pm, Norman Peelman <npeel...@cfl.rr.comwrote: Quote:
Mtek wrote: Quote:
On May 26, 4:22 pm, Norman Peelman <npeel...@cfl.rr.comwrote: Quote:
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:
> Quote: Quote:
$timing[$x]['Count'] = 0;
$timing[$x]['Start'] = date("g:i:s");
> Quote: Quote:
$timing[$x]['Count']++;
> Quote: Quote:
echo var_dump($timing);
> Quote: Quote:
--
Norman
Registered Linux user #461062- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote:
What is the difference between that and something like this:
> Quote:
* $tables[$x] = array('Acronym' =$table_data[0],
* * * * * * * * * * * 'List' * *=$table_data[1],
* * * * * * * * * * * 'Name' * *=$table_data[2]);
> Quote:
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.
> > Quote:
* * * $summary[$x]['seating'] = array('Seating' =$row[0],
* * * * * * * * * * * * * * * * * * * 'Count' * =$row[1]);
> Quote:
Is the word 'seating' like a section title or something?
> >
--
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....... | | | | re: Multi Array?
Mtek wrote: Quote:
On May 26, 7:01 pm, Norman Peelman <npeel...@cfl.rr.comwrote: Quote:
>Mtek wrote: Quote:
>>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.
>> Quote:
>>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. jstucklex@attglobal.net
================== | | | | re: Multi Array?
Mtek wrote: Quote:
On May 26, 4:22 pm, Norman Peelman <npeel...@cfl.rr.comwrote: Quote:
>Mtek wrote: Quote:
>>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. Quote:
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?- | | | | re: Multi Array?
Mtek wrote: Quote:
On May 26, 4:22 pm, Norman Peelman <npeel...@cfl.rr.comwrote: Quote:
>Mtek wrote: Quote:
>>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. jstucklex@attglobal.net
================== | | | | re: Multi Array?
On May 26, 4:22*pm, Norman Peelman <npeel...@cfl.rr.comwrote: Quote:
Mtek wrote: > Quote:
I'm not sure how to do this. *Let's say I have an array that looks
like this:
> Quote:
$timing[$x] = array('Count' *=0);
> Quote:
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:
> Quote:
$timing[$x] = array('Start' *=date ("g:i:s"));
> Quote:
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?
> Quote:
Along those same lines, can I do something like this: *$timing[$x]
['Count']++;
> Quote:
I'm looking for examples, but not finding any on the web. *If someone
can help, I'd really appreciate it.
> > >
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??? | | | | re: Multi Array?
On May 26, 4:22*pm, Norman Peelman <npeel...@cfl.rr.comwrote: Quote:
Mtek wrote: > Quote:
I'm not sure how to do this. *Let's say I have an array that looks
like this:
> Quote:
$timing[$x] = array('Count' *=0);
> Quote:
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:
> Quote:
$timing[$x] = array('Start' *=date ("g:i:s"));
> Quote:
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?
> Quote:
Along those same lines, can I do something like this: *$timing[$x]
['Count']++;
> Quote:
I'm looking for examples, but not finding any on the web. *If someone
can help, I'd really appreciate it.
> > >
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 |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|