Copying one array into another

How do I copy all of the contents of the $_POST array into my own array?

TomTees

You can try array_merge http://php.net/manual/en/function.array-merge.php

That doesn’t sound exactly like what I want.

My goal is to copy an existing array (i.e. $_POST) into a new array (i.e. MyArray) and not change the structure of the original array (e.g. Keys) in the new array.

TomTees

$myArray = $_POST;

It’s that simple?! :blush:

I don’t have to define anything first?

TomTees

nope, try it

why would you want to do that? $_POST is already in Array depending on how you have it coded.

Because I wanted to copy in the values of $_POST into an array that is a data element in my own class.

That way I can handle any sized form and have an object I can pass around containing whatever form values are thrown at it.

TomTees