PHP using map array? -
i new php , trying use map array. $arr2
hold values of different types of fruits. when execute following code, tells me "apple"
undefined index. can please show me how can correct following code can accesses different values?
<?php main_fun (); function main_fun () { $arr2 = array(); num2_data ($arr2); echo "<br>.".$arr2["apple"]["q1"]; // quadrant 1 value of apple echo "<br>.".$arr2["orange"]["q2"]; // quadrant 2 value of orange } function num2_data (&$arr2) { $arr2 = array("apple" => array("q1" => 1.1380711874577, "q2" => 1.7625118400083, "q3" => 1.8957417329238, "q4" => 2.4453545524829)); $arr2 = array("orange" => array("q1" => 1.1380711874577, "q2" => 2.5045795667914, "q3" => 1.8957417329238, "q4" => 2.7192512120757)); } ?>
in function, second assignment $arr2 overwriting previous (with apple)
to add element, can set this...
$arr2["orange"] = array("q1" => 1.1380711874577, "q2" => 2.50457956679 ...
Comments
Post a Comment