Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7867667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:45:54+00:00 2026-06-03T00:45:54+00:00

beginner PHP programmer here trying to use the mailchimp API… I keep getting this

  • 0

beginner PHP programmer here trying to use the mailchimp API…

I keep getting this PHP error with regard to my first line of code here…. I am posting a value from a form, as you can see, but I am not sure what is going on.

The error:
Warning: Variable passed to each() is not an array or object in xxxxxxx on line 24 (which is the first line)

while (list($key, $val) = each($_POST['MCgroup'])) {
        $interest .= ($count>0 ? ", " : "");
        $interest .= $val;
        $count++;
    }

    echo $interest; //echos NOTHINGblank
    $mergeVars = array(
                       'INTERESTS'=>$interest
                        );

    echo $mergeVars; //echos the word ARRAY

From what I have researched, OBVIOUSLY I am not passing an actual ARRAY… but also from what I have found, my syntax all seems correct. (But I could be overlooking something).

Here is the part of the form code that is passing the values

 <input type="hidden" name="MCgroup" id="MCgroup" value="My Interest One" />
 <input type="hidden" name="MCgroup" id="MCgroup" value="My Interest Two" />

or I COULD change it to

<input type="hidden" name="MCgroup" id="MCgroup" value="My Interest One, My Interest Two" />

I just am not sure how to make THAT into an array.

Help please! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:45:55+00:00Added an answer on June 3, 2026 at 12:45 am

    You can set your <input> to have an array name by suffixing [], do something like this:

    <input type="hidden" name="MCgroup[]" id="MCgroup" value="My Interest One" />
    <input type="hidden" name="MCgroup[]" id="MCgroup" value="My Interest Two" />

    then check it by:

    print_r($_POST['MCgroup']);

    Where I assume you set form method to POST.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a beginner level php programmer. I was trying to use the MVC
I am beginner in PHP. I am trying to parse this xml file. <relationship>
First of all, I'm a beginner to PHP. And have posted a question here:
PHP beginner working from a tutorial. I'm trying to do a simple upload from
i'm a beginner to php. i need to use php function which process some
I'm a beginner in php, and I am trying to create a login and
I am a PHP beginner and saw on the forum this PHP expression: My
This is a topic that, as a beginner to PHP and programming, sort of
EDIT: The plugin in question is located here . PHP beginner here using a
I'm a beginner at PHP, and I'm still trying to work out proper file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.