Re: Need help accessing the key array. [message #185413 is a reply to message #185412] |
Sat, 29 March 2014 21:05 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 3/29/2014 4:49 PM, Kongthap Thammachat wrote:
> <?php
>
> $rates = array(
> array("animal" => 0, "color" => 0, "rate" => 5),
> array("animal" => 0, "color" => 1, "rate" => 10),
> array("animal" => 0, "color" => 2, "rate" => 15),
> array("animal" => 1, "color" => 0, "rate" => 20),
> array("animal" => 1, "color" => 1, "rate" => 25),
> array("animal" => 1, "color" => 2, "rate" => 30),
> array("animal" => 2, "color" => 0, "rate" => 35),
> array("animal" => 2, "color" => 1, "rate" => 40),
> array("animal" => 2, "color" => 2, "rate" => 45),
> array("animal" => 3, "color" => 0, "rate" => 50),
> array("animal" => 3, "color" => 1, "rate" => 55),
> array("animal" => 3, "color" => 2, "rate" => 60)
> );
>
> $input_animal = 1;
> $input_color = 2;
>
> ?>
>
> How to access the $rates array to echo the associated rate of "animal" => 1 and "color" => 2 ? (which is 30), should i re-designed the $rates array?
>
> Thanks
>
$rates is an array from [0]..[n]. So in this case it would be $rates[5].
Part of the problem is the way you're doing this is very hard to
understand. But not knowing what you're trying to do, I can't give you
any better recommendations.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
|
|
|