Hello.
I have an array of results from mysql relational tables. It looks similar to this:
array(10) {
[0]=>
object(stdClass)#14 (35) {
["eventID"]=>
string(1) "1"
["eventTitle"]=>
string(7) "EVENT 1"
["artistID"]=>
string(1) "1"
["artistName"]=>
string(8) "ARTIST 1"
["artistDescription"]=>
string(20) "ARTIST 1 description"
// etc.
}
[1]=>
object(stdClass)#15 (35) {
["eventID"]=>
string(1) "1"
["eventTitle"]=>
string(7) "EVENT 1"
["artistID"]=>
string(1) "2"
["artistName"]=>
string(8) "ARTIST 2"
["artistDescription"]=>
string(20) "ARTIST 2 description"
// etc.
}
[2]=>
object(stdClass)#16 (35) {
["eventID"]=>
string(1) "1"
["eventTitle"]=>
string(7) "EVENT 1"
["artistID"]=>
string(1) "3"
["artistName"]=>
string(8) "ARTIST 3"
["artistDescription"]=>
string(20) "ARTIST 3 description"
// etc.
}
[3]=>
object(stdClass)#17 (35) {
["eventID"]=>
string(1) "2"
["eventTitle"]=>
string(7) "EVENT 2"
["artistID"]=>
string(1) "5"
["artistName"]=>
string(8) "ARTIST 5"
["artistDescription"]=>
string(20) "ARTIST 5 description"
// etc.
}
[4]=>
object(stdClass)#17 (35) {
["eventID"]=>
string(1) "2"
["eventTitle"]=>
string(7) "EVENT 2"
["artistID"]=>
string(1) "7"
["artistName"]=>
string(8) "ARTIST 7"
["artistDescription"]=>
string(20) "ARTIST 7 description"
// etc.
}
//etc.
}
I want to make a multidimensional array which would look like this one:
array(2) {
[1]=>
array(9) {
["eventID"]=>
string(1) "1"
["eventTitle"]=>
string(7) "EVENT 1"
["artists"]=>
array(3) {
[1]=>
array(2) {
["artistName"]=>
string(8) "ARTIST 1"
["artistDescription"]=>
string(20) "ARTIST 1 description"
}
[2]=>
array(2) {
["artistName"]=>
string(8) "ARTIST 2"
["artistDescription"]=>
string(20) "ARTIST 2 description"
}
[2]=>
array(2) {
["artistName"]=>
string(8) "ARTIST 3"
["artistDescription"]=>
string(20) "ARTIST 3 description"
}
}
}
[2]=>
array(9) {
["eventID"]=>
string(1) "2"
["eventTitle"]=>
string(7) "EVENT 2"
["artists"]=>
array(3) {
[1]=>
array(2) {
["artistName"]=>
string(8) "ARTIST 5"
["artistDescription"]=>
string(20) "ARTIST 5 description"
}
[2]=>
array(2) {
["artistName"]=>
string(8) "ARTIST 2"
["artistDescription"]=>
string(20) "ARTIST 7 description"
}
[2]=>
array(2) {
["artistName"]=>
string(8) "ARTIST 3"
["artistDescription"]=>
string(20) "ARTIST 7 description"
}
}
}
}
I started to create an array in a FOR
loop but I was stuck with creating this artists[] array and I'm totally confused last 30 mins =)
Thank you in advance for any help!