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. Link to comment https://forums.phpfreaks.com/topic/97242-oh-i-am-hoping-theres-a-genius-that-can-help-me-with-this-php-array-problem/ Share on other sites More sharing options...
rhodesa Posted March 21, 2008 Share Posted March 21, 2008 print $order->quotes['methods'][0][cost]; Link to comment https://forums.phpfreaks.com/topic/97242-oh-i-am-hoping-theres-a-genius-that-can-help-me-with-this-php-array-problem/#findComment-497588 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. :-* Link to comment https://forums.phpfreaks.com/topic/97242-oh-i-am-hoping-theres-a-genius-that-can-help-me-with-this-php-array-problem/#findComment-497591 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! Link to comment https://forums.phpfreaks.com/topic/97242-oh-i-am-hoping-theres-a-genius-that-can-help-me-with-this-php-array-problem/#findComment-497613 Share on other sites More sharing options...
cooldude832 Posted March 21, 2008 Share Posted March 21, 2008 they aren't operators. Link to comment https://forums.phpfreaks.com/topic/97242-oh-i-am-hoping-theres-a-genius-that-can-help-me-with-this-php-array-problem/#findComment-497614 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? Link to comment https://forums.phpfreaks.com/topic/97242-oh-i-am-hoping-theres-a-genius-that-can-help-me-with-this-php-array-problem/#findComment-497621 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.