multi dimensional arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kareem100
Forum Newbie
Posts: 11
Joined: Sat May 01, 2010 5:39 pm

multi dimensional arrays

Post by kareem100 »

Hi,

I am learning PHP at a local college.

I come across the folowing code, which I have questions about

while ($row = mysqli_fetch_array($result))
{
$jokes[] = array('id' => $row['id'], 'text' => $row['joketext'];
}

I want to know

1) is jokes[] a multi-dimensional array ?

2) If it is how do you refer to the joketext of the third joke. is this answer $jokes[3,2]?
phu
Forum Commoner
Posts: 61
Joined: Tue Mar 30, 2010 6:18 pm

Re: multi dimensional arrays

Post by phu »

1. Yes, it is a multi-dimensional array.

2. The syntax is $arr[$x][$y]. You can nest to an arbitrary depth (if you happen to think that's a good idea). ;)
Post Reply