I have this table, resulting from a SELECT + INNER && LEFT JOIN (this is the spiegation of the NULL values).
cookery id_cookery detail id_detail
Locale 1 NULL NULL
Regionale 2 NULL NULL
Regionale 2 Abruzzese 1
Nazionale 3 NULL NULL
Internazionale 4 NULL NULL
Internazionale 4 Africana 3
Internazionale 4 Americana 82
My framework put this result in this array:
Array
(
[0] => Array
(
[cookery] => Locale
[id_cookery] => 1
[detail] =>
[id_detail] =>
)
[1] => Array
(
[cookery] => Regionale
[id_cookery] => 2
[detail] =>
[id_detail] =>
)
[2] => Array
(
[cookery] => Regionale
[id_cookery] => 2
[detail] => Abruzzese
[id_detail] => 1
)
[3] => Array
(
[cookery] => Nazionale
[id_cookery] => 3
[detail] =>
[id_detail] =>
)
[4] => Array
(
[cookery] => Internazionale
[id_cookery] => 4
[detail] =>
[id_detail] =>
)
[5] => Array
(
[cookery] => Internazionale
[id_cookery] => 4
[detail] => Africana
[id_detail] => 3
)
[6] => Array
(
[cookery] => Internazionale
[id_cookery] => 4
[detail] => Americana
[id_detail] => 82
)
)
By the way, I need to create an array with this aspect, grouping the "cookery" in only 4 field (Locale, Regionale, Nazionale and Internazionale) and IF the cookery has "detail", putting them sub his key.
A sort of:
Array (locale => '',
regionale => Abruzzese
nazionale => '',
Internazionale => Africana, Americana)
(probably I did not write correctly this Array, but I hope that you understand).
1) I tried first of all to save in a temp array only the different id_cookery, to use later
if (!in_array($value['id_cookery'],$tmp))
{
$tmp[] = $value['id_cookery']);
}
But sincerly I don't know what I can do with it...
2) I tried to save in another array only the values != NULL
if ($value['detail']!='')
{
$temp[$key][] = $value['cookery'];
$temp[$key][] = $value['detail'];
$temp[$key][] = $value['id_cookery'];
}
But at this time... How I can merge the arrays and obtain my goal? Or can you help, following any road?
Thank you very, very much.
PS How I can post a mysql table to view correctly? I saw in others answer that posted Mysql table seems a jpeg from terminal... :)