Reputation: 103
I have a problem.. i want to combine two array..
multidimensional
Array 1.
Array
(
[0] => 1
[1] => 2
[2] => 1
[3] => 2
[4] => 1
)
Array 2
Array
(
[0] => asdf
[1] => asdfa
[2] => asdf
[3] => asdf
[4] => asdfasdf
)
I need solution like this...
Array
(
[1] => asdf
[2] => asdfa
[1] => asdf
[2] => asdf
[1] => asdfasdf
)
If there is any solution in multidimensional array please let me know.
After combine both array i need to use with foreach or any method and i want to insert array data in Database
Like this..
ID | Value | S_ID
--------------------
1 | asdf | 1
2 | asdfa | 2
3 | asdf | 1
4 | asdf | 2
4 | asdfasdf | 1
I so confused and i try lot of function and method from last 6 hours but no luck :(..
Upvotes: 0
Views: 131
Reputation: 99921
Iterate over the two arrays together and create a multidimensional array:
$newarray = array();
foreach($array1 as $key => $value) {
$newarray[] = array(
'Value' => $value,
'S_ID' => $array2[$key],
);
}
print_r($newarray);
Upvotes: 2