FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Need help accessing the key array.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Need help accessing the key array. [message #185412] Sat, 29 March 2014 20:49 Go to previous message
Kongthap Thammachat is currently offline  Kongthap Thammachat
Messages: 2
Registered: March 2014
Karma:
Junior Member
<?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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Most secure way to reset a password via email link
Next Topic: Strange but true! Working with interfaces in PHP
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 16:55:23 GMT 2024

Total time taken to generate the page: 0.04109 seconds