What are Multi-Dimensional Arrays in PHP

today we're going to talk about something called multi-dimensional arrays inside PHP we're going to talk about what they are how to create them and how to output something inside browser using multi-dimensional arrays so the basic idea behind multi-dimensional array is that we can have an array-like to want to have here that has three pieces of data inside of it daniel john and jane and instead of having data inside this array we can have another array inside of it so forward to go ahead and delete Daniel for example now we have two pieces of data and instead of the first data I'm just gonna go and create another array so right now as you guys can see we're starting to get something I might get a bit confusing because we might be thinking why do we need to have an array inside an array one example could be if you pull out data from a database that you have online and you want to insert it inside an array now because data from a database when you pull it out already gets pulled out s an array when he inserted into an empty array like the one we have here you get a raise insider rates so we need to learn how to actually you know use them and what they are so right down inside this first array that have inside my ray I'm gonna go and put a couple of numbers i'm going to say we have 12 and we have 32 so we have some numbers now just to make this more nice to look at I'm just gonna go to move this down so we have everything on separate lines i'm just going to move down like this and like this and this is closed it off there so now it looks a bit more clean to look at so we can actually go and do now is we could actually go and test this forward to go down on next line here and do something called print R which is a function have inside PSP nor to spit out a raise in side the process he had a look like going to a prince on the score our parentheses i'm going to put in my variable data inside the parentheses if i go back to the website refresh you guys can see you get some numbers now what we have here is the first array inside our document which is variable data inside this array inside space number one which is zero because we start from zero we have another array which is right here and as we have one two and three inside this array then afterwards from the first array we have our second number or second data which is John and then we have the third data which is game so as you guys can see we now have an array inside spot number one inside the original array now you might be asking how do we then spit it out because let's say I have this multi-dimensional array and I want to spit out some data if i go ahead and comment out our print our go down to the next line and say I want to echo global data and I want to make art the first piece of data which is the array we have been here and I want to spit out for example one from disarray now however to if I want to spit out data number two I could go ahead and say I have you know spot number one which is 0 1 which is John if i were to echo that you would get John but what if i want to get the data from an array inside an array what we can do here is we can say okay we have spot number one or zero inside the original array up here which is a separate array and if i want to go into that array we need to add a second brackets afterwards and from here we can put in the number of the data we want to pull out from it so if you want to pull out number one we say this your spot went first to raise this array and then the sewers but from data array is one to refresh the browser you guys can see we get one again change this to one then we get to very basic and so that's basically what a multi-dimensional array is and in the future you will be using it when we get into stuff like object oriented PHP programming which is a different type of programming which is a different type of program using PHP code where you structure everything a bit different then you will need to know how to do multi-dimensional arrays which is why it's important that you understand you can actually put a raise in Saturday's like we did here now if you guys are interested in how to actually do bout data from a multi-dimensional array like we did here in the previous episode we talked about how to get data from a database and into the internal ray I talked about how to insert I have to loop out the data from what Mitchell array using the free to do we have inside PHP so if you guys want to see how to do that you can go and watch the last episode we did that at the end so because enjoy it i'll see you guys next time