Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] Pomoc przy zrozumieniu skryptu
-beska-
post
Post #1





Goście







  1. // Select all entries from the menu table
  2. $result=mysql_query("SELECT id, label, link, parent FROM menu ORDER BY parent, sort, label");
  3. // Create a multidimensional array to conatin a list of items and parents
  4. $menu = array(
  5. 'items' => array(),
  6. 'parents' => array()
  7. );
  8. // Builds the array lists with data from the menu table
  9. while ($items = mysql_fetch_assoc($result))
  10. {
  11. // Creates entry into items array with current menu item id ie. $menu['items'][1]
  12. $menu['items'][$items['id']] = $items;
  13. // Creates entry into parents array. Parents array contains a list of all items with children
  14. $menu['parents'][$items['parent']][] = $items['id'];
  15. }


Jest taki skrypt, i nie rozumiem jak buduje się ta tablica menu, a konkretnie.
$menu['items'][$items['id']]= $items to znaczy, że np $menu['items'][1] jest równe czemu? nazwie np samochody?
i
$menu['parents'][$items['parent']][] = $items['id'] dlaczego w tym $menu jest dodatkowe [] na końcu? i to się równa jakiejś liczbie tak?
Proszę o to aby ktos mi to wyjaśnił
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 06:26