| Parse out associative array
|
JohnKelly

msg:4312437 | 5:26 pm on May 14, 2011 (gmt 0) | Try as I might, I cannot parse out this array. I have an array, when I run var_dump($array->chart()); it outputs the following
array(5) { ["i1"]=> string(3) "430" ["c1"]=> string(2) "21" ["ct2"]=> string(5) "98%" ["ec3"]=> string(6) "68.4" ["ea4"]=> string(5) "3.9" }
I would like to get something like: i1 = 430 c1 = 21 ct2 = 98% ec3 = 68.4 ea4 = 3.9 ... but I cannot parse out the array, for some reason I always find associative arrays difficult. Can anyone please help?
|
agent_x

msg:4312477 | 7:39 pm on May 14, 2011 (gmt 0) | Is it not simply extract($array) ?
|
agent_x

msg:4312479 | 7:44 pm on May 14, 2011 (gmt 0) | Or am I not understanding what you were trying to do? If it's just to echo out the contents of the array it's something like foreach($array as $key=>$value) { echo $key . " = " . $value . "<br>"; }
|
JohnKelly

msg:4312603 | 5:26 am on May 15, 2011 (gmt 0) | Thanks agent_x for the tip on extract($array)! Here is what I used:
extract($array->chart(), EXTR_PREFIX_SAME, "wddx"); echo "$i1, $c1, $ct2, $ec3, $ea4";
|
|
|