How to sort flat array into multidimensional tree
问题 I have a table like id catagory suboff 1 software 0 2 programming 1 3 Testing 1 4 Designing 1 5 Hospital 0 6 Doctor 5 7 Nurses 5 9 Teaching 0 10 php programming 2 11 .net programming 2 How to write a code to get all these information in a multidimensional array based on the suboff as follows, -software --programming ---php programming --- .net programming --testing --designing -hospital --doctor --nurses -teaching 回答1: Assuming MySQL as your DB engine: // We'll need two arrays for this $temp