0

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?

1
  • echo $_POST['hellomail']['campaign_list']['list_id']; and echo $_POST['hellomail']['campaign']['campaign_id']; Commented Mar 21, 2013 at 10:57

2 Answers 2

2

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"];
Sign up to request clarification or add additional context in comments.

Comments

2

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"];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.