Jump to content

The array_map( ) Function Revisited


iwato

Recommended Posts

I would like to preserve the keys to the associative input array ($varnames) and replace the values with those of $_POST.  This function replaces the both the keys and values and returns an index array with the $_POST values.

	function replace_value($a, $b) {
		$a = $b;
		return $a;
	};
	$varnames = array_map(replace_value, $varnames, $_POST);
	print_r($varnames);						

Any suggestions?

Roddy

Link to comment
Share on other sites

Never mind unless, of course, you know something about array mapping that I do not and would like to teach me.  Certainly I am willing to learn.

For the moment, I have resolved the problem using the array_combine( ) method.

Roddy

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
×
×
  • Create New...