0
OT: PHP Multidimensional arrays and creating them?
LEGEND
,
/t5/dreamweaver-discussions/ot-php-multidimensional-arrays-and-creating-them/td-p/1074769
Sep 20, 2006
Sep 20, 2006
Copy link to clipboard
Copied
I have a process that is generating successive sets of data,
where each set
consists of three 'fields', or separate values, e.g.,
set1 = 'a', 'b', and 'c'
set2 = 'd', 'e', and 'f'
As each set is generated, I want to save it in an ongoing array so that when
the process is finished all of the data is contained within that array as
successive 'rows'.
Can someone give me a nudge for this in PHP, please?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
consists of three 'fields', or separate values, e.g.,
set1 = 'a', 'b', and 'c'
set2 = 'd', 'e', and 'f'
As each set is generated, I want to save it in an ongoing array so that when
the process is finished all of the data is contained within that array as
successive 'rows'.
Can someone give me a nudge for this in PHP, please?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/dreamweaver-discussions/ot-php-multidimensional-arrays-and-creating-them/m-p/1074770#M109785
Sep 20, 2006
Sep 20, 2006
Copy link to clipboard
Copied
Murray *ACE* wrote:
> Can someone give me a nudge for this in PHP, please?
Shove... :)
You'll have to be a bit more precise in saying how your sets are
created. In general terms, though, just create a loop and add the items
using square bracket notation:
$row = array();
while (condition is true) {
$row[] = $set;
}
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
> Can someone give me a nudge for this in PHP, please?
Shove... :)
You'll have to be a bit more precise in saying how your sets are
created. In general terms, though, just create a loop and add the items
using square bracket notation:
$row = array();
while (condition is true) {
$row[] = $set;
}
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/dreamweaver-discussions/ot-php-multidimensional-arrays-and-creating-them/m-p/1074771#M109786
Sep 20, 2006
Sep 20, 2006
Copy link to clipboard
Copied
Oops <stumble>....
Hmm - OK.
Here's what I'm doing now:
$i=0;
$myarray[$1][0]=dataitem1;$myarray[$i][1]=dataitem2;$myarray[$i][2]=dataitem3;
$i++;
and I'm looping through this for a specified number of iterations.
Is that the most efficient way?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
"David Powers" <david@example.com> wrote in message
news:eerm14$1bm$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Can someone give me a nudge for this in PHP, please?
>
> Shove... :)
>
> You'll have to be a bit more precise in saying how your sets are created.
> In general terms, though, just create a loop and add the items using
> square bracket notation:
>
> $row = array();
> while (condition is true) {
> $row[] = $set;
> }
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/
Hmm - OK.
Here's what I'm doing now:
$i=0;
$myarray[$1][0]=dataitem1;$myarray[$i][1]=dataitem2;$myarray[$i][2]=dataitem3;
$i++;
and I'm looping through this for a specified number of iterations.
Is that the most efficient way?
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
"David Powers" <david@example.com> wrote in message
news:eerm14$1bm$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Can someone give me a nudge for this in PHP, please?
>
> Shove... :)
>
> You'll have to be a bit more precise in saying how your sets are created.
> In general terms, though, just create a loop and add the items using
> square bracket notation:
>
> $row = array();
> while (condition is true) {
> $row[] = $set;
> }
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/dreamweaver-discussions/ot-php-multidimensional-arrays-and-creating-them/m-p/1074772#M109787
Sep 20, 2006
Sep 20, 2006
Copy link to clipboard
Copied
Murray *ACE* wrote:
> $i=0;
> $myarray[$1][0]=dataitem1;$myarray[$i][1]=dataitem2;$myarray[$i][2]=dataitem3;
> $i++;
>
> and I'm looping through this for a specified number of iterations.
$myarray = array();
for ($i = 0; $i < $number_of_iterations; $i++) {
array_push($myarray[$i], dataitem1, dataitem2, dataitem3);
}
http://www.php.net/manual/en/function.array-push.php
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
> $i=0;
> $myarray[$1][0]=dataitem1;$myarray[$i][1]=dataitem2;$myarray[$i][2]=dataitem3;
> $i++;
>
> and I'm looping through this for a specified number of iterations.
$myarray = array();
for ($i = 0; $i < $number_of_iterations; $i++) {
array_push($myarray[$i], dataitem1, dataitem2, dataitem3);
}
http://www.php.net/manual/en/function.array-push.php
--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
LATEST
/t5/dreamweaver-discussions/ot-php-multidimensional-arrays-and-creating-them/m-p/1074773#M109788
Sep 20, 2006
Sep 20, 2006
Copy link to clipboard
Copied
Ahhh - eggsellect. <stands up>
Thanks!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
"David Powers" <david@example.com> wrote in message
news:eerob7$49l$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> $i=0;
>> $myarray[$1][0]=dataitem1;$myarray[$i][1]=dataitem2;$myarray[$i][2]=dataitem3;
>> $i++;
>>
>> and I'm looping through this for a specified number of iterations.
>
> $myarray = array();
> for ($i = 0; $i < $number_of_iterations; $i++) {
> array_push($myarray[$i], dataitem1, dataitem2, dataitem3);
> }
>
> http://www.php.net/manual/en/function.array-push.php
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/
Thanks!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================
"David Powers" <david@example.com> wrote in message
news:eerob7$49l$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> $i=0;
>> $myarray[$1][0]=dataitem1;$myarray[$i][1]=dataitem2;$myarray[$i][2]=dataitem3;
>> $i++;
>>
>> and I'm looping through this for a specified number of iterations.
>
> $myarray = array();
> for ($i = 0; $i < $number_of_iterations; $i++) {
> array_push($myarray[$i], dataitem1, dataitem2, dataitem3);
> }
>
> http://www.php.net/manual/en/function.array-push.php
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

