I will call you back again to another video lecture in PHP.
And in this video lecture we go ahead and look at arrays in PHP.
Oh, I saw arrays are very important in PHP development because it plays a vital role in collecting
large number of information.
Now we have on the screen you can see I have a different variables and I have first one player, one
player, two, three, four and five.
And now it is easy for me to go ahead and see equal.
Let me say player one.
And if I go ahead I'm going to get okay.
So I have an error right in here.
And that is says unexpected end of pi and In line nine.
All right.
So here I didn't close this.
So this place is not closed.
Now go ahead and check it out again.
So I have a Ronaldo right in there.
So what happens here is that if I want to create a variable and I'm creating different variables of
a different players.
And this is a collection of players.
So it is easier for me to use an array and put everything in just one variable because array is descending
as variables.
But the difference between arrays and a specific individual variables is that each of this variable
just collects one piece of information, it stores just one piece of information, which is just player
one stars.
Ronaldo.
What if we should change this players to an array?
We can be able to collect everything and we can actually access this.
So if I want to access player three, I'll go ahead and echo.
Uh, this is uh.
Player four right?
Player four and I forgot how to run this.
We can see it now.
I will go ahead and, uh, then go ahead and comment on this.
All right.
So I'll go ahead and comment on this, and, uh, I'll go ahead and remove this.
Now, the echo has not run in there.
What to create an array.
Because an array helps us to collect multiple information.
So it is a container that helps us to collect multiple information of the same elements.
So the elements is going to be just the same let's say for players instead of creating different different
players we go ahead and create just an array of players and everything is added.
An array is going to be an element.
So let's go ahead and create a variable called uh player.
And uh let's this player go ahead and have an upgrade.
All right.
So I click on that.
And now I shouldn't just go ahead and do that.
Let me go ahead and say an array.
All right.
Now it's good to have an open and close parentheses and semicolon at the end.
Now I'll go right in here.
I'll take a Ronaldo.
And that is the first element you're going to put in there.
Now we'll go ahead and collect a messi.
That is the second element right in there.
Now we go over here I collect Mbappé and we go right in here and publicity.
So the next one is a Ousmane and then we go ahead and put in there.
Now the last one is Jorge.
You know I'm also a player.
So let's go ahead and put in there.
Now we have collected all these.
You will not ask me how can we be able to display this information?
Permission is that ever possible?
So using an array we are going to use what is called index.
So now over here let's go ahead and say something.
The very first one here Ronaldo is is index zero.
The next one here is our Messi is index one.
Then the next one here is going to be index two.
Then the next one here is index three.
And the last one here is index four.
So whenever you are using an array whatever you have is an index inside of that array.
So it starts from index zero and not one.
So if I should call Ronaldo I should be calling index zero.
And whatever that is there we print it out.
Now let's go ahead and comment on this so that we don't run into an error when we run this code.
Now let's go ahead and equal out player.
And then we're going to use a bracket.
And there if I want to assess, Missy.
I'll go ahead and put a layer one that is index one.
Now I'll go ahead and save this and let's check it out.
So we have a fatal error.
And that says of course undefined player.
And.
In line 17.
And let's go over here and check out what is the problem.
So this is player and this is player.
So what happens is that we missed the dollar sign.
So we missed the dollar sign in line 17.
And let's go over here and refresh this again.
So we have Missy right in here.
So now always remember to put the dollar sign I sorry for missing out the dollar sign on this.
Now let's go ahead and check out index zero.
And then let's go ahead and check it out Coronado.
And let's check out index four.
And uh, let's go ahead and check it out.
And that is George.
So using the iris you can be able to collect so many elements.
So whatever it is inside the array is an element.
And you can access these elements using the index numbers starting from index zero.
The very first element in an array is index zero.
Now I cannot change this as well.
Let me go ahead and see.
I want to change index two.
If I want to change index two, go ahead and remember to put the dollar sign when we say player.
And uh let's go ahead and say index two.
Now changes to any name.
So which name are we going to put them in and say this is a seller.
Now go ahead and press semicolon.
And I've also printed out the index to go ahead and pass index two at the echo of the players and the
refresh rate.
Let's check it out.
So that is seller.
So you can be able to see you can change any name.
You can be able to change any index in that way.
So there are many things to do using an array.
So as time goes on we go ahead and check out more on that.
And we play around arrays.
That is very interesting learning about array because without an array, if you want to collect a large
elements of the same category, you will be creating different variables.
And that that will make your code not to look very clean.
All right.
So with this which we just did right in here, you can be able to see that we created something so good.
And it looks very nice and a very clean.
So thanks to array for making it very simple for us.
And I believe that you too.
You love what you are seeing.
So pull it down, play around with it.
And if you have any question under this video lecture, please use the question and answer section and
I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.