 Everybody this is Brian and welcome to the 16th lamp tutorial. Wow. We are cruising right through these Today we're going to learn what an array is So what is an array? Well, we've made variables. What say you got to make a lot of variables like your boss wants you to Write a program that Evaluates a hundred cars. Wow You're gonna make a hundred variables well Kitty, what are you doing? My cat is acting all crazy. Sorry about that Recording honey, go away so an array is One variable that holds multiple variables For example my cat. I'm sure you can hear her. It's one cat holding multiple meows. Yes. I'm talking about you This cat is crazy. Anyways So you can see how you can make multiple variables. Well an array Let's jump down here Here we have a variable called cars You see this array function and all this stuff behind it What we're doing is we're making one variable hold an array or multiple variables You see how you have cars zero equal Saab cars one equal. What is this number? Well, the bracket number in bracket. That's the index inside of the array Remember zero is always the first position. So it's going to be a zero based array. So zero one two three Zero one two three. That's how you get those positions And here's what the actual code would look like if you were going to play around with this Car zero equals Saab cars one equal Volvo car two equal BMW three Toyota and then you're gonna echo these out The above code will print out. You guessed it Saab Volvo and Swedish cars Wow Arrays look complex. They are a little bit of a brain bender if you're not used to them so we're gonna actually break arrays into a few tutorials and We're gonna say people Equal array Brian Eric and Sally I'm just making names up at the off top of my head now We have our array. Let's say we want to get the second item Eric and print it out on the screen Remember this is a zero based system. So zero one Two so we need the one So we'll say echo People and there's Eric. I know it looks a little funny having a number one, but it's the second one Remember, it's a zero based right if we put a zero in there It's gonna grab this guy at the zero position in this case Brian me So that's an array very simple very easy to use comes in very handy You won't really grasp the reason why you need an array until we get into four loops. Then you'll really start to understand Well, I'm gonna keep these Fairly short fairly simple. Oh, yeah, I should probably cover how to actually assign a value to an array Let's say People all right, so we're going to just catnate that out This is incredibly hard to type talk and pet the cat all at the same time Trying to keep the cat quiet. So she can let me do this tutorial So what we're gonna do here is we've got an array of people in this case Brian Eric sally And we're gonna echo out the number one index in this case Eric and Then we're going to change that value to Bob So what we're doing is replacing Eric with Bob and then echoing it out that way you can see That this index of the array is actually changing see Eric Bob. Whoops. I must have hit the wrong key thing So there's Eric and we're changing that to Bob and then we're just printing it out Notice how the index never changes, but the value does So you can make different indexes in the array be different values And there are a ton of array functions, which we're not going to get into in this tutorial But just know that they're out there. You can do things like sorting filtering Splitting, I mean a whole ton of things but right now just understand What an array is and how to manipulate the values inside of that array? Let's offer this tutorial. I hope you found this educational entertaining and my cat apparently wants to say hi