Jump to content

Take keys and values out of an array and make a new one


clay1

Recommended Posts

Say I have my $_POST array

 

Let's say I have 3 items- Name, Email, Comment

 

I need to take name and email and make a new array with them let's call it User[]

 

And then I need an array with just the comment.

 

So I should end up with 2 separate arrays.

 

Suggestions?

Assuming there is only 1 value for a Name, Email and Comment:

foreach ($_POST as $key => $value)
{
   if($key == 'Name' || $key == 'Email')
      $personArray[$key] = $value;
   else
      $commentArray[$key] = $value;
}
print_r($personArray);
print('<br/>'."\n");
print_r($commentArray);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.