Lesson #9: PHP Arrays

PHP arrays store multiple key-value pairs in a single variable. Learn to declare arrays with the array keyword, access values using bracket notation like $info['email'], and remove elements with unset.
Chapters
Hello, it's me again with another tutorial. In this one, we're going to be learning about PHP arrays. Arrays are useful for storing data or variables and making it really small and really easy to access them. Let's take a look at an array. This is a basic array. Now, uh, basically how an array works is, uh, you— or how you use it is you have your array And you insert one of these brackets. You insert the key to the value that you want to access. And you close that, and that will return the value. Arrays are sort of hard to explain. Basically, it's like this. You have an array, and it's basically a variable that stores a bunch of variables. I'm just going to explain this really simple. But basically, you designate like an ID or whatever you want to call it, and you give that ID a value. You can do this over and over, so you can have something like an array where you have an ID of username, an ID of password, an ID of email, and therefore later on when you want to access it, you can do something like info email and it will pull up the value you assigned for that email value or email variable. So you can change stuff like this, and then our variable. We can also do stuff like strings. x equals 5, whatever we want to have it. Of course, we can just echo everything out. We can echo out whatever we want. And that would echo out 5 because we assigned 5 right there and we echoed out 5. To delete a variable, all you have to do is unset r and then our variable name, or we could just do the whole array. That is pretty much it for arrays, basically. When you To declare the variable, you just have to do array and then our ID. We do this equals than or greater than sign, which sort of looks like an arrow, and then the value of that ID. So yeah, arrays are very simple. I use them all the time. They're very good, very neat. It's perfect. Thanks for watching.










