简体   繁体   English

从发布到php文件的数组中获取单个值

[英]Get single value from array that is posted to php file

I am using mailchimp's webhook feature to (eventually) run a script on my app that will mark a user as unsubscribed from the newsletter if they unsubscribe through mailchimp. 我正在使用mailchimp的webhook功能(最终)在我的应用程序上运行一个脚本,如果他们通过mailchimp取消订阅,则该脚本会将用户标记为从新闻简报中取消订阅。

Mailchimp is passing the following array to my script using POST. 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
        )

)

My issue is, how can I get the [email] value out of it so that I can then pass that as a variable to update the database? 我的问题是,如何从中获取[email]值,以便随后将其作为变量传递以更新数据库?

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

Try this code: 试试这个代码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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