 Hey everybody, this is Brian. Welcome to the 18th lamp tutorial today. We're making discussing multi-dimensional arrays I promise the last of the array tutorials I know that we've kind of beaten this up a little bit arrays in our partner part of any programming language So let's dive right in What is a multi-dimensional array? Well, let's think back an array is a value or I should say a variable that holds multiple values So what's a multi-dimensional array? Well, it's a you guessed it Variable that holds other arrays How does that work exactly? here's our variable families and It is an array this whole big chunk and the first value in the or should say the first index in the array Because this is a associative array It is actually an array in itself. I Know that sounds confusing, but don't worry. We're gonna cover this Open up your trusty IDE And let's just say pet Owners Equal array We'll say Brian And we're going to make this an array. Let's say shakes not shanks. Drup Yeah, I'm naming my cats. These are not their full names and Laser thingy. That's one of the cats toys. Did I actually misspell laser? I did. Oh my gosh You got to be talented when you misspell laser I call laser thinking one of the pets because I have to constantly feed a battery so to keep the cats occupied All right now we're going to say Heather my daughter And let's say she's got a An array Let's say her pet is fishy. She's got pet fish and then let's just say Mike I cannot spell today at all Mike's got an array of pets Let's say he's got doggy because he's got a dog and you can tell I'm really creative with names here and Let's give him a really unique pet like What was that thing I call? Oh, yeah Liger. It's a combination between a lion and a tiger. Those actually do exist They're quite freaky if you've ever seen one So wow, let's look at the syntax of this thing As you've guessed it working with multi-dimensional rays comes with its own headaches I mean look at the syntax of that you misspell one little thing and that whole variable was just shot So how do you access items in a multi-dimensional array? Well, I'm glad you asked So let's just keep it simple here and we'll say Brian. Whoops Okay sensitive and let's just say we want to access the first item in here Shakes, that's our first item Then if you wanted to access the second one remember, this is a zero based index failure and then Third one Laser thingy Now let's grab Heather here and let's grab the first one in Heather Now let's grab the second one in Heather Oh, there's nothing there because see how Heather's array only has one item That is another interesting question is how do you tell how many things are in an array? Well, you use the function called count You see the syntax for count is count the number of elements in a variable usually an array and it's a mixed variable So what we're going to do is we're just going to say Copy this little guy so you're grabbing the first value That matches Heather So what it's doing is it's going to pet owners. It's grabbing. Okay. Here's the first value Is that got in the label of Heather? No, so then here's the another one. Does that have a label of Heather? Yes, so it grabs that one and then it says, okay, what is the value for that value Well, this is an array We can prove that it's an array By simply printing it out. See now. Let's give this a more meaningful example So we are echoing out The Heather index the first value in that multi-dimensional array, which is fishy see right here fishy and Then we're just echoing out the Heather index or I should say the Heather value Which is this right here? What that saying is it's an array so you know this is an array and Then we're going to count the elements in that array Heather one So let's grab Mike here. We haven't done anything with Mike. So let's Plug Mike in there and see what happens Notice how it says doggy because doggy is the first element in the Mike array And then we're going to grab that and showing that This is an array We could put strings integers whatever we want, but it's important to note that it's printing out array Which means it knows PHP is a typeless programming language means it doesn't really care what you put into a value or into a variable You can put an integer a string a double a single etc. It doesn't care, but it keeps track internally and that's what it's saying is hey I know that's an array and then we're saying how many items are in the Mike array to Pretty complex subject and I have to admit multi-dimensional arrays in the real world Really aren't used too heavily there are better programming Ways of doing things, but we're not going to cover those just yet So that's all for now. This is Brian. Thank you for watching