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.

Link to comment
Share on other sites

-> 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.