foreverdita Posted March 21, 2008 Share Posted March 21, 2008 This is from another programmers code, and I cannot get it to work. I have called a global array in this page: global $order; print_r ($order->quotes); The contents of this global array print looks like this: Array ( [id] => payment [module] => Standard [methods] => Array ( [ 0 ] => Array ( [id] => payment [title] => Standard shipping to US [cost] => 4.95 ) ) ) All I want to do is find the way to print the [cost] value of 4.95. I cannot get this to work. Does anyone know how to help me? I will be forever grateful. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 21, 2008 Share Posted March 21, 2008 print $order->quotes['methods'][0][cost]; Quote Link to comment Share on other sites More sharing options...
foreverdita Posted March 21, 2008 Author Share Posted March 21, 2008 print $order->quotes['methods'][0][cost]; I don't know how to thank you - absolutely genius, I tried everything to get it to work - you are brilliant. :-* Quote Link to comment Share on other sites More sharing options...
Tjorriemorrie Posted March 21, 2008 Share Posted March 21, 2008 Hey, was hoping someone can help me. What is the -> and => operators? And what are they called? How do they work? Thanks! Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 21, 2008 Share Posted March 21, 2008 they aren't operators. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 21, 2008 Share Posted March 21, 2008 -> is used to access a member (aka variable) inside an Object print $obj->foobar; //Prints the value of the 'foobar' member inside the $obj Object => is used when declaring an associative array $myArr = array( 'key1' => 'Value for key 1', 'key2' => 'Value for key 2', ); //Also used with foreach foreach($myArr as $key=>$val){ } Make sense? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.