I have a code that fetches rows from my mysql and displays in a categorized format, but I couldn't understand the line $array[$rows['parent_id']][] = $rows; from the code. The code looks like:
<?php
function display_menus_revised()
{
$sql = "SELECT * FROM categories";
$query = mysql_query($sql) or die(mysql_error());
$array = array();
if (mysql_num_rows($query)) {
while ($rows = mysql_fetch_array($query)) {
$array[$rows['parent_id']][] = $rows;
}
loop_array($array);
}
}
?>
When the above code is executed the list of items are shown properly with their names but I don't understand what is the use of the extra [] in the line $array[$rows['parent_id']][]. Please do explain I am very much new to php.