Replace one arrays keys with another arrays values in php

adriaan

New Member
I want to map form fields to database fields.I have two arrays..One array is the data and contains the form field id as the key and the form field value as the value.\[code\]$data = http://stackoverflow.com/questions/15735480/array("inputEmail"=>"[email protected]","inputName"=>"someone"... etc\[/code\]I also have an array which i intended to use as a map. The keys of this array are the same as the form fields and the values are the database field names.\[code\]$map = array("inputEmail"=>"email", "inputName"=>"name"... etc\[/code\]What i want to do is iterate over the data array and where the data key matches the map key assign a new key to the data array which is the value of the map array.\[code\]$newArray = array("email"=>"[email protected]", "name"=>"someone"...etc\[/code\]My question is how? Ive tried so many different ways im now totally lost in it.
 
Back
Top