简体   繁体   中英

Get array value in php

This is the array i want to mc_gross value. please help

Array
(
    [id] => 5
    [txn_id] => 1fadfa1sfsa2
    [log] => Array
(
    [mc_gross] => 298.44
    [invoice] => 0856545471323
    [protection_eligibility] => Eligible
    [address_status] => confirmed
    [item_number1] => 12299
    [payer_id] => UTU3f7TLQ6DLX4
    [tax] => 0.00
    [address_street] => 1 Main St
    [payment_date] => 02:10:29 May 28, 2015 PDT
    [payment_status] => Completed
    [charset] => windows-1252
    [address_zip] => 95131
    [mc_shipping] => 0.00
    [mc_handling] => 0.00
    [first_name] =>Rohit
    [mc_fee] => 8.95
    [address_country_code] => US
    [address_name] => Rohit
    [notify_version] => 3.8
    [custom] => 
    [payer_status] => verified
    [business] => sunny@gmail.com
    [address_country] => United States
    [num_cart_items] => 1
    [mc_handling1] => 0.00
    [address_city] => San Jose
    [verify_sign] => AHr7LP.QXtufNfq97cbEdHHkqfNkJAtdXVkTwL.GBwGZwJBQ5GAJaqaXx
    [payer_email] => rohit@hotmail.com
    [mc_shipping1] => 0.00
    [tax1] => 0.00
    [txn_id] => 1FV62057CK3146235
    [payment_type] => instant
    [last_name] => Vishwakarma
    [address_state] => CA
    [item_name1] => Centro Yas Island Rotana - Demo
    [receiver_email] => sunny@gmail.com
    [payment_fee] => 8.95
    [quantity1] => 1
    [receiver_id] => 6Y6GRJS8NA8JE
    [txn_type] => cart
    [mc_gross_1] => 298.44
    [mc_currency] => USD
    [residence_country] => US
    [test_ipn] => 1
    [transaction_subject] => 
    [payment_gross] => 298.44
    [ipn_track_id] => 8656eb7f3009dd4
)

    [posted_date] => 2015-05-28 09:10:34
)

您可以简单地将其作为

echo $array_name['log']['mc_gross'];
$VARIABLE_NAME['log']['mc_gross']

您可以将其输出为:

echo $VARIABLE_NAME['log']['mc_gross'];

这样尝试

echo $array_name["log"]["mc_gross"];

只需使用此:

$YOUR_VARIABLE['log']['mc_gross']
$arr= Array
(
    [id] => 5
    [txn_id] => 1fadfa1sfsa2
    [log] => Array
(
    [mc_gross] => 298.44
    [invoice] => 0856545471323
    [protection_eligibility] => Eligible
    [address_status] => confirmed
    [item_number1] => 12299
    [payer_id] => UTU3f7TLQ6DLX4
    [tax] => 0.00
    [address_street] => 1 Main St
    [payment_date] => 02:10:29 May 28, 2015 PDT
    [payment_status] => Completed
    [charset] => windows-1252
    [address_zip] => 95131
    [mc_shipping] => 0.00
    [mc_handling] => 0.00
    [first_name] =>Rohit
    [mc_fee] => 8.95
    [address_country_code] => US
    [address_name] => Rohit
    [notify_version] => 3.8
    [custom] => 
    [payer_status] => verified
    [business] => sunny@gmail.com
    [address_country] => United States
    [num_cart_items] => 1
    [mc_handling1] => 0.00
    [address_city] => San Jose
    [verify_sign] => AHr7LP.QXtufNfq97cbEdHHkqfNkJAtdXVkTwL.GBwGZwJBQ5GAJaqaXx
    [payer_email] => rohit@hotmail.com
    [mc_shipping1] => 0.00
    [tax1] => 0.00
    [txn_id] => 1FV62057CK3146235
    [payment_type] => instant
    [last_name] => Vishwakarma
    [address_state] => CA
    [item_name1] => Centro Yas Island Rotana - Demo
    [receiver_email] => sunny@gmail.com
    [payment_fee] => 8.95
    [quantity1] => 1
    [receiver_id] => 6Y6GRJS8NA8JE
    [txn_type] => cart
    [mc_gross_1] => 298.44
    [mc_currency] => USD
    [residence_country] => US
    [test_ipn] => 1
    [transaction_subject] => 
    [payment_gross] => 298.44
    [ipn_track_id] => 8656eb7f3009dd4
)

    [posted_date] => 2015 to-05-28 09:10:34
)

you can get mc_gross value

echo $arr['log']['mc_gross']

Try It now: Get a mc_gross value

<?php

$array= Array
(
    [id] => 5
    [txn_id] => 1fadfa1sfsa2
    [log] => Array
(
    [mc_gross] => 298.44
    [invoice] => 0856545471323
    [protection_eligibility] => Eligible
    [address_status] => confirmed
    [item_number1] => 12299
    [payer_id] => UTU3f7TLQ6DLX4
    [tax] => 0.00
    [address_street] => 1 Main St
    [payment_date] => 02:10:29 May 28, 2015 PDT
    [payment_status] => Completed
    [charset] => windows-1252
    [address_zip] => 95131
    [mc_shipping] => 0.00
    [mc_handling] => 0.00
    [first_name] =>Rohit
    [mc_fee] => 8.95
    [address_country_code] => US
    [address_name] => Rohit
    [notify_version] => 3.8
    [custom] => 
    [payer_status] => verified
    [business] => sunny@gmail.com
    [address_country] => United States
    [num_cart_items] => 1
    [mc_handling1] => 0.00
    [address_city] => San Jose
    [verify_sign] =>   AHr7LP.QXtufNfq97cbEdHHkqfNkJAtdXVkTwL.GBwGZwJBQ5GAJaqaXx
    [payer_email] => rohit@hotmail.com
    [mc_shipping1] => 0.00
    [tax1] => 0.00
    [txn_id] => 1FV62057CK3146235
    [payment_type] => instant
    [last_name] => Vishwakarma
    [address_state] => CA
    [item_name1] => Centro Yas Island Rotana - Demo
    [receiver_email] => sunny@gmail.com
    [payment_fee] => 8.95
    [quantity1] => 1
    [receiver_id] => 6Y6GRJS8NA8JE
    [txn_type] => cart
    [mc_gross_1] => 298.44
    [mc_currency] => USD
    [residence_country] => US
    [test_ipn] => 1
    [transaction_subject] => 
    [payment_gross] => 298.44
    [ipn_track_id] => 8656eb7f3009dd4
)

    [posted_date] => 2015 to-05-28 09:10:34
)
 ?>

This Array Use

  <?php
  $value=$array["log"]["mc_gross"];
  echo $value;
?>

OR

 <?php
 foreach($array["log"] => $key=>$value){
  if($key=="mc_gross"){
    echo $value 
  }

 }
<?php

只需echo $arr['log']['mc_gross']获得所需的mc_gross

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM