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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -