how do i combine these arrays and use a specific value as key/index?
here's sample array i'm playing with:
Array
(
[0]=>john
[1]=>peter
)
Array
(
[dept]=>engineering
[sub]=>trigonometry
[time]=>08:00
)
what i want to achieved is like this:
Array
(
[john]=>john
[dept]=>engineering
[sub]=>trigonometry
[time]=>08:00
[peter]=>peter
[dept]=>engineering
[sub]=>trigonometry
[time]=>08:00
)
thanks in advance guys, hope u can help me with this. appreciate it.
I think you may want to associate the value of the first array with the values of the second array.
$finalArray = array();
foreach($firstArray as $name) {
$finalArray[$name] = $secondArray;
}
print_r($finalArray);
You will get :
Array
(
[john] => Array
(
[dept]=>engineering
[sub]=>trigonometry
[time]=>08:00
)
[peter] => Array
(
[dept]=>engineering
[sub]=>trigonometry
[time]=>08:00
)
)
Does this help you?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.