Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Turning a $_POST into a array


ghost's Avatar
0 0

how do i make what i get from $_POST into a array?


ghost's Avatar
0 0
$post[1] = $_POST('otherthing');
$post[2] =  $_POST('thingthree';```

is that what you mean? that should work...

EDIT: if thats not it try this: http://www.w3schools.com/php/func_filter_input_array.asp

ghost's Avatar
0 0

i mean i have a text area, and i have multiple things in it seperated by lines, how do i put each line in its own spot, in the array?


ghost's Avatar
0 0

nope that wasnt it either, is there any other way i can run threw the value of each line?


ghost's Avatar
0 0

The PHP post var is already an array, so unless you're filtering data, and then putting it into another array, there is really no point… Just use $_POST. But, here is my solution :)

$userInput = array();
foreach ($_POST as $key => $value)
{
    $userInput[$key] = $value;
}

If that's not what you're after, could you please explain in more detail what you are trying to achieve?

Good luck, -Jay.


ghost's Avatar
0 0

i have a TEXTAREA and the USERNAMES are put on differant lines on the TEXTAREA, and i need to run THREW the USERNAMES and TRY TO LOG IN with them on a differant site


ghost's Avatar
0 0

Then use Regex.


Mr_Cheese's Avatar
0 1

am i missing something?!

$_POST is an array in the first place.

but maybe you want this:

$name = Array( 'firstname' => $_POST['firstname'], 'secondname' => $_POST['secondname'] );


ghost's Avatar
0 0

i have a text area, and i have multiple things in it seperated by lines, how do i put each line in its own spot, in the array Assuming you had a text area with the name "text" and the contents looked like:

username2
username3
username4```

If you wanted to put each of those usernames into an array like a[0]="username1", a[1]="username2" etc then I think darkcoder had what you wanted with:

> $a=explode("\n",$_POST["text"]);
but his post got deleted.