Php array format output question, ask the gods I have the following table
How can I let him output the following array format based on the type and typeid? Thank you.
Array ([0] => array ([0] => [1] => wedding service [2] => mechanical equipment [3] => hospital medical service [4] => lighting and lighting [5] => education and training [6] => chemical coatings [7] => beauty and fitness [8] => catering and food [9] => Car Services) [1] => array ([0] => [1] => regular [2] => two columns [3] => three columns [4] => grid ))
Reply to discussion (solution)
Read after Query
while($row = mysql_fetch_assoc($rs)) { $res[$row['type'][] = $row['typevalue'];}$res = array_values($row);
Read after Query
while($row = mysql_fetch_assoc($rs)) { $res[$row['type'][] = $row['typevalue'];}$res = array_values($row);
Xuzuning moderator. I tried to report an error on the page. $ Res [$ row ['type'] [] here there are multiple brackets. If this parameter is removed, an error occurs.
The error is ruled out. $ res = array_values ($ row); why?
Oh, there is a bracket missing.
$ Res [$ row ['type'] [] = $ row ['typevalue'];
Oh, there is a bracket missing.
$ Res [$ row ['type'] [] = $ row ['typevalue'];
If the xuzuning moderator is changed to your latest version, a page error occurs. The error message is as follows: $ res = array_values ($ row );
Error message: Warning: array_values () expects parameter 1 to be array, boolean given in
This line points to $ res = array_values ($ row );
My fault!
$ Res = array_values ($ res );
Oh, there is a bracket missing.
$ Res [$ row ['type'] [] = $ row ['typevalue'];
-----------------------------------
After the xuzuning moderator is completed, it is $ res = array_values ($ row); here it is wrong. The $ row is not an array, so it will cause an error. it has been changed. thank you for your ideas.
My fault!
$ Res = array_values ($ res );
Done. (* ^__ ^ *) Xi ...... Thank you.