-6

可能重复:从PHP 中的 json_decode JSON 解码
获取数组结果

我需要帮助将一些选定的 $_POST 数据存储到 mysql 中。我不知道变量名称,它是来自 carloom 的即时通知功能,例如 paypal ipn。

ipn.php

<?php
$data = print_r($_POST); 

$to = "hello065-65@yahoo.com";
$subject = "My subject";
$txt = $data;

mail($to,$subject,$txt,$headers);
?>

当我使用print_r($_POST);

我在电子邮件中收到以下内容..

order: {"billingFirstName":"sachin","billingLastName":"gupta","billingCompany":"df","billingAddress1":"33","billingAddress2":"","billingCity":"Chandigarh","billingState":"CT","billingPostalCode":"44444","billingCountry":"US","billingEmail":"hello065-65@yahoo.com","billingPhone":"","shippingFirstName":"","shippingLastName":"","shippingCompany":"","shippingAddress1":"","shippingAddress2":"","shippingCity":"","shippingState":null,"shippingPostalCode":null,"shippingCountry":null,"date":"Wed Apr 11 15:18:40 EDT 2012","transid":497070762,"invoice":1012,"grandTotal":"$0.00","payMethod":"none","comments":"","cartContents":[{"id":"48401","title":"Alex & Me - 10% Coupon","options":"","qty":"1","price":"0.00"}],"subTotal":"$0.00","discountAmount":"$0.00","discountTitle":"Complimentary Order","salesTaxTitle":"CT Sales Tax","salesTaxAmount":"$0.00","shippingTitle":null,"shippingAmount":"$0.00"}<br> 

谁能帮助我,如何将billingFirstName sachin数据存储到 mysql 中。

4

1 回答 1

2

对我来说它看起来像 JSON

你可以试试。。

$order_details = json_decode($_POST['order']);
$the_variable_you_want = $order_details['billingFirstName'];

编辑:更新了示例以更清楚地向您展示如何获取所需的变量。

于 2012-04-12T18:52:32.547 回答