Jump to content

Oh, I am hoping there's a genius that can help me with this php array problem


foreverdita

Recommended Posts

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.

-> 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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.