【问题标题】:Get single value from array that is posted to php file从发布到 php 文件的数组中获取单个值
【发布时间】:2014-01-31 07:28:54
【问题描述】:

我正在使用 mailchimp 的 webhook 功能(最终)在我的应用程序上运行一个脚本,如果用户通过 mailchimp 取消订阅,该脚本会将用户标记为未订阅时事通讯。

Mailchimp 正在使用 POST 将以下数组传递给我的脚本。

Array
(
    [type] => unsubscribe
    [fired_at] => 2014-01-12 12:56:23
    [data] => Array
        (
            [action] => unsub
            [reason] => manual
            [id] => 1b3a2f11af
            [email] => email@domain.com
            [email_type] => html
            [ip_opt] => xxx.xxx.xxx.xxx
            [web_id] => 128403001
            [merges] => Array
                (
                    [EMAIL] => email@domain.com
                    [FNAME] => FNAME
                    [LNAME] => LNAME
                )

            [list_id] => 5c30250cdb
        )

)

我的问题是,如何从中获取 [email] 值,以便我可以将其作为变量传递以更新数据库?

【问题讨论】:

    标签: php arrays post mailchimp


    【解决方案1】:

    $email = $_POST ['data']['email'];

    【讨论】:

      【解决方案2】:

      试试这个代码:

      $result_array = $_POST;
      echo $result_array["data"]["email"]; // or $_POST["data"]["email"];
      

      【讨论】:

        猜你喜欢
        • 2012-07-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-06-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多