This is an amateur question (so apologies in advance if im overlooking something really obvious but i’ve been hunting around PHP.net for some clues but havent figured it out yet), im deciphering this code someone else did for a friends site and kind of just got lost.
what the code is doing is creating an array for a database, and then the site is calling the information back based on time stamps and the sort. for some reason some things aren’t showing up so i’m just trying to get my head through it:
$TYPES_EXPO = array("Type1","Type2","Type3","Type4","Type5","Type6","Type7");
$currentarray = $debe->runSql("SELECT * FROM expositions WHERE from<='$nu' AND to>='$nu' ORDER BY from");
if(count($currentarray)>0)
echo "<h1>Current Exhibitions</h1>";
for($i=0; $i<count($currentarray);$i++)
{
echo "<b>" . $currentarray[$i][3] . "</b>";
so in that last line, what is the [3] referencing? theres more of it in other parts of the code, different integers such as [6] and [7] in that similar configuration which seem arbitrary to me, just can’t seem to get my finger on it…
The 3 is referencing the 4th element (0 is the first element) inside the multidimensional array
$currentarray.So for example you have an array
$person$person[1][3]would refer to the integer 21.I hope this helps 🙂
//edit: just as a tip, don’t use count() in the foreach. Assign a variable vefore so the function doesn’t get called a thousand times when you have thousand array items.