I have seen a tutorial where someone uses the syntax $data = [];
to declare an array instead of $data = ();
My notes and web references refer to the round braces instead of square braces.
In the same tutorial, when attempting to display data from a database in tabular format, instead of using while($rows = $results->mysqli_fetch_assoc())
, the person opts to use while($rows = $results->fetch_assoc())
. I was under the impression that the standard query should be mysqli_fetch_assoc()
as standard.
Another example:
while($rows = $results->fetch_assoc())
{ $comps[] = $rows; }
Can anyone shed some light on these differences? The person’s code still seems to run, but I am confused as to what is the more correct option in terms of both the array declaration and fetch query.