I have 2 arrays, 1 called $person and the other called $classes. I'd like to merge the 2 together into 1 array and assign a name to item in the new merged array. Therefore creating an associative array as opposed to using keys that array_merge seems to be made by default using the array_merge function. (For clarity 1 person has multiple classes.)
Currently I have this:
($person)
[1]=>
array(2) {
["Name"]=>
string(1) "Bobby Moore"
["Age"]=>
string(18) "36"
($classes)
[1]=>
array(2) {
[0]=>
array(11) {
["Class ID"]=>
string(1) "12"
["Class Title"]=>
string(18) "Math 101"
[1]=>
array(11) {
["Class ID"]=>
string(1) "13"
["Class Title"]=>
string(18) "Math 102"
[1]=>
array(11) {
["Class ID"]=>
string(1) "14"
["Class Title"]=>
string(18) "Math 103"
Is it possible to get the following result?
[person]=>
array(1) {
[0]=>
array(11) {
["Name"]=>
string(1) "Bobby Moore"
["Ages"]=>
string(18) "35"
[Classes]=>
array(2) {
[0]=>
array(11) {
["Class ID"]=>
string(1) "12"
["Class Title"]=>
string(18) "Math 101"
[1]=>
array(11) {
["Class ID"]=>
string(1) "13"
["Class Title"]=>
string(18) "Math 102"
[1]=>
array(11) {
["Class ID"]=>
string(1) "14"
["Class Title"]=>
string(18) "Math 103"
Currently I'm using array_merge($person ,$classes); which unfortunately is an array sorted by keys.
I hope this makes sense! Thank you in advance!