php array replace across the keys
So i have an array containing information that I need to join on another
table, for each key I need to join it onto the form_lookup table. my
question is what would be the fastest and correct possible way to do this?
I already have the form_information array
attempt:
$form_titles =array();
foreach (form_information[0] as $key => $value) {
select NAME from form_lookup where CODE_ID = $key;
$query = $this->db->get();
}
$form_names = $query->result_array();
$form_titles[] = $campus_forms;
now i need to replace the keys from form_information with the keys from
form_titles array s.
$final_array = array_replace($form_information, $replacements);
form_information## (initial array)
[0] => Array
(
[FIELD_1] => information
[FIELD_2] => information
[FIELD_3] => information
[FIELD_4] => information
[FIELD_5] => information
...
)
Table form_lookup
CODE_ID | NAME
--------------
FIELD_1 | Name
--------------
FIELD_2 | ID
-------------
FIELD_3 | Contact
--------------
FIELD_4 | Lookup
-------------
FIELD_5 | Campus
(final array)
[0] => Array
(
[Name] => information
[ID] => information
[Contact] => information
[Lookup] => information
[Campus] => information
...
)
No comments:
Post a Comment