Ask a Question related to PHP Development, Design and Development.
-
Ike #1
Associate multidim array
I have the following table I am going to read from a database:
ROD S_PD S_RF BZ_BRG
0.63 8.7 38 5.7
1.00 12.1 41.6 13.5
1.38 13.6 45.9 13.5
1.75 13.6 48.2 19
2.00 15.5 69 21
I would like to create an associateive array such that, for example, for an
array $data:
$data[1.38][S_RF] == 45.9
any idea how I might do this? Thanks, Ike
Ike Guest
-
Version 10 will not associate with swf files
Please tell me what to do as I have tried all the window's methods. I installed today and do not have a desktop icon or an entry in All Programs.... -
Associate a description to a jpg
Hi! I hope somebody can help me: In my web page there are some buttons that allow to load several jpeg pictures in the same main movie,I created... -
Removing elements from associate array.
Elo! I've got a problem with removing elements from associate array (php). Above you'll find a schematic structure of my array: ARRAY ------... -
Associate buttons with keyboard?
I'm relatively new to flash and far from familiar with Action Script, however, is there a way to associate buttons being pressed on a webpage with... -
re-associate photoshop with .psd files
hi, i have photoshop 5.5 and windows98se i recently installed irfanview 3.8 and since i did that, something strange has happened: normally... -
Ike #2
Re: Associate multidim array
I specified this incorrectly - I am reading the database table in java, and
from java, writing php code. So, what I want to do, is determine the syntax
for specifing an associateive multidensional array such that
$data[1.38][S_RF] == 45.9;
I have a start on it as:
$data = array(
("S_PD" => 8.7 "S_RF" => 38 "BZ_BRG" => 13.5),
("S_PD" => 12.1"S_RF" => 41.6"BZ_BRG" => 13.5),
....
But this then gives the first index of the array as a number, and not
associatevely, i.e. $data[2][S_RF] == 45.9; How can I specify this so that
both indexes into the array are associative? Thanks, Ike
"Ike" <rxv@hotmail.com> wrote in message
news:SoIGc.10599$yy1.3790@newsread2.news.atl.earth link.net...an> I have the following table I am going to read from a database:
>
> ROD S_PD S_RF BZ_BRG
>
> 0.63 8.7 38 5.7
> 1.00 12.1 41.6 13.5
> 1.38 13.6 45.9 13.5
> 1.75 13.6 48.2 19
> 2.00 15.5 69 21
>
>
> I would like to create an associateive array such that, for example, for> array $data:
>
> $data[1.38][S_RF] == 45.9
>
> any idea how I might do this? Thanks, Ike
>
>
Ike Guest
-
Virgil Green #3
Re: Associate multidim array
"Ike" <rxv@hotmail.com> wrote in message
news:9uIGc.10605$yy1.10457@newsread2.news.atl.eart hlink.net...and> "Ike" <rxv@hotmail.com> wrote in message
> news:SoIGc.10599$yy1.3790@newsread2.news.atl.earth link.net...> an> > I have the following table I am going to read from a database:
> >
> > ROD S_PD S_RF BZ_BRG
> >
> > 0.63 8.7 38 5.7
> > 1.00 12.1 41.6 13.5
> > 1.38 13.6 45.9 13.5
> > 1.75 13.6 48.2 19
> > 2.00 15.5 69 21
> >
> >
> > I would like to create an associateive array such that, for example, for> I specified this incorrectly - I am reading the database table in java,> > array $data:
> >
> > $data[1.38][S_RF] == 45.9
> >
> > any idea how I might do this? Thanks, Ike
> >
> >syntax> from java, writing php code. So, what I want to do, is determine theLike Java, PHP has no such thing as a multi-dimensional array. Rather it has> for specifing an associateive multidensional array such that
> $data[1.38][S_RF] == 45.9;
>
> I have a start on it as:
>
> $data = array(
> ("S_PD" => 8.7 "S_RF" => 38 "BZ_BRG" => 13.5),
> ("S_PD" => 12.1"S_RF" => 41.6"BZ_BRG" => 13.5),
> ...
> But this then gives the first index of the array as a number, and not
> associatevely, i.e. $data[2][S_RF] == 45.9; How can I specify this so that
> both indexes into the array are associative? Thanks, Ike
>
single-dimensional arrays. However, the value of any given array element may
be an array. Since these arrays are actually maps (which provides the
ability to have associative arrays), you can't have a "multi-key" array in
the sense you are describing. In Java, you would probably create a new class
that represented each key value you wanted and then put your entry in a Map
object using the multi-valued key object as the key and your numeric table
entry as the value.
That said, you can produce one PHP array that has another PHP array as a
value. This does require that your second key be represented as a string as
the key to a PHP array must be an integer or a string:
$data = array('S_PD'=> array('0.63'=>8.7, '1.00'=>12.1, '1.38'=>13.6,
'1.75'=>13.6, '2.00'=>15.5),
'S_RF'=> array('0.63'=>38, '1.00'=>41.6, '1.38'=>45.9,
'1.75'=>48.2, '2.00'=>69),
'BZ_BRG'=> array('0.63'=>5.7, '1.00'=>13.5, '1.38'=>13.5,
'1.75'=>19, '2.00'=>21),
);
print_r($data);
Virgil Green Guest



Reply With Quote

