Reputation: 2525
This is probably a simple question but i have tried for hours without getting anything out:
I'm customizing an opensource WordPress Plugin. When I post on my customized PHP file and var_dump()
the $_POST
variables I get the following:
array(7) {
["hellomail"] => array(3) {
["email"] => array(7) {
["subject"] => string(4) "asda"
["from_name"] => string(14) "Myplugin"
["from_email"] => string(12) "[email protected]"
["replyto_name"] => string(14) "Test"
["replyto_email"] => string(12) "[email protected]"
["params"] => array(1) {
["schedule"] => array(2) {
["day"] => string(10) "2013/03/21"
["time"] => string(8) "00:00:00"
}
}
["email_id"] => string(2) "25"
}
["campaign_list"] => array(1) {
["list_id"] => array(1) {
[0] => string(1) "4"
}
}
["campaign"] => array(1) {
["campaign_id"] => string(2) "24"
}
}
["receiver-preview"] => string(10) "[email protected]"
["_wpnonce"] => string(10) "999938595d"
["_wp_http_referer"] => string(66) "/wp-admin/admin.php?page=testpage&action=editDetails&id=25"
["action"] => string(8) "savelast"
["roll_redir"] => string(0) ""
["submit-send"] => string(6) "Senden"
}
What I need is the ["campaign_id"]
and the ["list_id"]
. I really have no idea how to get these values, is there an easy way to access them?
Upvotes: 0
Views: 68
Reputation: 2491
This is the way the array looks:
array(7) {
["hellomail"]=> array(3) {
["email"]=> array(7) {
["subject"]=> string(4) "asda"
["from_name"]=> string(14) "Myplugin"
["from_email"]=> string(12) "[email protected]"
["replyto_name"]=> string(14) "Test"
["replyto_email"]=> string(12) "[email protected]"
["params"]=> array(1) {
["schedule"]=> array(2) {
["day"]=> string(10) "2013/03/21"
["time"]=> string(8) "00:00:00"
}
}
["email_id"]=> string(2) "25"
}
["campaign_list"]=> array(1) {
["list_id"]=> array(1) {
[0]=> string(1) "4"
}
}
["campaign"]=> array(1) {
["campaign_id"]=> string(2) "24"
}
}
["receiver-preview"]=> string(10) "[email protected]"
["_wpnonce"]=> string(10) "999938595d"
["_wp_http_referer"]=> string(66) "/wp-admin/admin.php?page=testpage&action=editDetails&id=25"
["action"]=> string(8) "savelast"
["roll_redir"]=> string(0) ""
["submit-send"]=> string(6) "Senden"
}
Try the below snippet to get at the particular array elements your looking for.
echo $_POST["hellomail"]["campaign_list"]["list_id"][0]."<br/>"
.$_POST["hellomail"]["campaign"]["campaign_id"];
Upvotes: 2
Reputation: 11340
world of php =)
echo $_POST["hellomail"]["campaign_list"]["list_id"]; // to get array
echo $_POST["hellomail"]["campaign_list"]["list_id"][0]; // to get first
echo $_POST["hellomail"]["campaign"]["campaign_id"];
Upvotes: 2