Jump to content

splitting an array


jimfog
 Share

Recommended Posts

I want to split an array in two other arrays. The functions I found in the PHP manual do that but I want to do it according to specific keys. meaning, I want to take specific key/values from the original array and pass them to a newly created array. The only was I have found to do it is manually, such as the code above:

end_user=array();$end_user[]=$_POST['username/e-mail'];

Do you think that there is anything wrong with such an implementation like the above?

Link to comment
Share on other sites

I don't really see the splitting part per se that you are talking about, but here a couple of other options.

$end_user = array($_POST['username'], $_POST['email']); //or$end_user = array(  'username' => $_POST['username'],  'email'		=> $_POST['email']);

Edited by thescientist
Link to comment
Share on other sites

Yes you are right, I am not clear in my code. But I would describe it like this: I take the values in the POST array and some of them I pass it to an X array and some of itto another array Y. Of course, the above is hardly evident from my code example-my mistake.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...