OH this is the 1st line right after the <?Php tag to start the file…
/* Thanks to help from JimL from http://www.phphelp.com/ for help in writing this working script!! */
OH this is the 1st line right after the <?Php tag to start the file…
/* Thanks to help from JimL from http://www.phphelp.com/ for help in writing this working script!! */
Finished product:
http://www.dallascowboyschat.com/forum/index
about 1/2 way down the page… under the Share button…
$game[‘gt’] is the CON/DIV/WC value. This line adds the game in this iteration under the CON/DIV/WC key of the $games array. The [] at the end means “add this value as a new array element”. Imagine a “con” game:
[php]$games = array(
“CON” => array(
0 => array( // added game as a new array element
“id” => // etc…
)
),
“DIV” => array(
),
“WC” => array(
)
)[/php]
Structuring the games under these keys is what actually gives us the ordering.
In the first foreach we are saying for each $games as $gametype => $subgames. Gametype refers to the array key, while subgames refers to the array value in the top array. You can call these variables whatever you want.
So in our case foreach ($games as $x => $y), x would be CON/DIV/WC, and y would be an array of all the games in this key
The $game variable here and the $game variable from the last loop are not connected. Again, you can call this whatever you want.
In this foreach we are looping over an array where we are not interested in the keys, so we do not use the $x => $y format, we using the simpler foreach ($array as $y). With this format we only get out the array value of each iteration. Adding $x => like in the last loop would gives us 0, 1, 2 etc as that are the default keys in an array.
Since we are inside a foreach that sets $subgames to the array of games of the game types, we use that $subgames array as the list of games to loop through.
[php]$games = array(
“CON” => array( // first iteration of outer loop
0 => array( // first iteration of inner loop
“id” => // etc…
),
1 => array( // second iteration of inner loop
“id” => // etc…
) // no more games, we break out of the inner loop
),
“DIV” => array( // second iteration of outer loop
0 => array( // first iteration of inner loop
“id” => // etc…
) // no more games, we break out of the inner loop
),
“WC” => array( // third iteration of outer loop
)
)[/php]
Np, I prefer to output php in html instead of html in php. One reason being markup in the IDE. Much easier to edit HTML when the editor is able to highlight it
No, there are far too many bad coding books available already
You could get an idea of what it would feel like though
http://www.phphelp.com/forum/the-occasional-tutorial/make-your-life-simpler-use-an-ide!/
http://www.phphelp.com/forum/the-occasional-tutorial/modern-web-development-let’s-develop-something-together
LOL yeah I’ve been reading and it’s not impressive. They don’t explain well and they certainly don’t always give good examples thereby confusing people even more…
But Thank you again and this is a GREAT reference for me because I’ll read this like 10 times… until it sinks in… your explanation makes perfect sense and now I understand that I was trying to make links to items that weren’t linked and there in was my confusion.