I will call you back again to another lecture in PHP.
And in this video lecture we go ahead and look at strings in PHP.
All right.
So we have always discussed about strings.
And right now we go ahead and focus just on strings alone.
So when we discuss about data types we talked about strings.
And when we discuss about variables we also discussed about strings.
Right now we are discussing about strings on its own.
So string is very important because anything we put in between a quotation mark is a string.
Now let's go ahead and say equal.
And if we go ahead and say this is a J Steve.
Oh I made a mistake.
So this is a just war academy.
All right.
Now if you have this undiagnosed semicolon at the end and if I refresh this, you see how just simple
academy this right inside that quotation mark.
Just simple Academy is a string.
So now we're going to look at different aspects of strings and what I'm, what I'm going to do or what
this string ah function does in PHP.
Now first of all I'm going to put this inside a a variable.
So let's go ahead and create a variable.
And I'm going to call that variable to be my wall.
So let my wall be equal to.
Guest wall.
Academy.
So my wall is equal to guest academy.
Or put a semicolon at the end.
Now if I want to echo this I will simply, simply say see my wall, then press semicolon at the end.
Then we refresh this.
We still have just the War Academy right in there.
Now there are many things we can actually do.
Maybe I want to make this just war academy to have everything go to in lower case.
What am I going to do?
I will go ahead and say echo.
Then I'm going to copy everything right in here.
And I'm going to say echo style.
So anytime you use style this is a string.
And I'll go ahead and say string to string to lower.
Oh I want to remove this just string to lower.
And then we go ahead and uh, list everything right inside there.
Now a war had on refresh this and you can see that everything is in lowercase.
Now you can actually go ahead and, uh, let's go ahead and copy everything we have right in here and
go down here, and I'm going to do that for oppa.
So if I do that for oppa, I'm going to change this from STL to lower to STL to oppa.
So I'm going to save this and I'm going to refresh this I have I just save all.
And the next one is just this one.
All right.
So because everything there is no brick stack tag day, there is no brick tag.
That is why we have everything in one line.
So let me go ahead and, uh, close this other one.
And if I run this, I have just the academy right in here.
So you can see that everything to oppa.
Now what if what if I want to assess only just a wall without assessing academy?
How can you be able to do that?
Walter says only just ignore that assistant academy.
Or maybe you assess only academy without just wall.
No, I will go ahead and, uh.
let's go ahead and echo this out.
So I want to say echo.
And then we go ahead and, uh, create what is called a substring.
So in that case, I want to collect just a portion of a string.
That means I'm collecting a substring right in here.
So I'm going to say so.
And then you add string.
This is a substring in PHP.
And now I'll go ahead and uh input my variable which is my wall.
Then I have to count these.
The first one here is
0123456789
1011.
That means I'm going to start from a.
So I'll go ahead and put 11.
Then put a semicolon at the end.
And let's refresh this academy.
So you can see I was able to get a portion of that strain, which is called a substring, and that is
academy.
So is that academy.
Maybe I want to start from I just want to take only a C, a D, let's say acad.
So that is I'm going to say this started from four.
And if I save this out of fresh I have a cat because I just need only this first four right in here.
Now this is about substring how to, you know, collect some portion of your string.
I'll go ahead and show us another one.
What if you want to calculate the length of this string?
Everything right in the sky let's say echo then STL length.
So if I go ahead I'm going to pass in my variable right in there and go ahead and say this is my wall.
And let's go here, refresh this and check it out.
So it means it is 18 characters that are right in here.
So we have 18 characters right in there.
So you use the SQL Len to be able to check out how many characters you have in a string.
So what if what if I want to get maybe only G.
So anytime you're working with a string, I want us to note this.
The first character I have here is zero.
Next one is next one is one, two, three, four, five, six, seven, eight, nine and so on to 18.
So the very first one is zero.
Now let's go ahead.
And uh, I'm going to comment on this so that it will always be here.
So our first one is zero.
And uh let's go ahead and check it out to make sure we have it.
So echo and I will go ahead and input in my variable my wall.
And then I'm going to pass the index zero of that.
If I pass in index zero then I go ahead and print out only the first one.
Or first is I check it out G.
So you can see I'm able to get G, because that is a first one right in there.
So if I go over here and input one, I refresh and half as a s.
Now remember we input 11 and a got academy.
So if I go back right here and put 11 I'm going to get just a correct out is a refresh.
And that is what we have right in here.
So I believe that this is really making sense to us because we need to know all this.
It helps us in our day to day execution of our programs.
Now there is another wall right in here.
What if I want to change?
Just wall to wall Academy.
To my academy?
Then I will go ahead and use what is called a string replace.
So go ahead and say echo zero underscore replace.
And now I want to be able to replace this wall with moi.
Now I'm going to pass in the first one which is a DST wall.
Then the next argument or the next parameter I'm going to put in here is going to be what you want to
use to replace that first one, which is just a wall.
So that is moi.
And then I'll go ahead and pass in my variable name, which is uh, my wall, because that is the string.
I want this to be executed off.
So go ahead and save this and let's refresh this.
And then what?
Academy are no longer just a war academy, so I hope that is really making sense.
That is really making sense.
So that is really very interesting.
So I believe that everything we are doing right in here is actually making sense to us.
And uh, I believe that, uh, with time, you're going to master everything.
Let me say I want to replace let's say I want to have my I'll go ahead and delete this and save.
And let's refresh this just for a memoir Academy, because I just want to replace only this portion,
you understand?
I want to replace just this portion alone.
So I've replaced the wall with suggestive Memoir Academy.
So if you put everything you have a pleasant everything right in there.
Everything right in there.
Okay, so what if you just wanted a place?
Let me say a half wall, and I want to call this.
Let's go ahead and remove this.
And I want to the place let me say G.
With e let's go ahead and save our refresh.
And we have Estival Academy and no longer Festival Academy.
So we have still four.
Academy because I just want to replace only the G.
You understand?
So I hope that is really very cool.
Now there is one more thing I'm going to show us before we run out.
So when I talked about, uh, the index, you kind of press an index.
Let me say, without.
Going this way, there is something I got to do.
Let me say I have a couple of days, and then I'm going to.
Okay.
Number four, start with a my variable name, which is my.
Whoa.
And then I'm going to pass in in the index I want to replace index zero now.
And that index zero is G.
And then I'll go ahead and say this is equal to.
In the first one I use a e.
Let me go ahead and say I'm going to use um p and then put a semicolon at the end.
And now let's go ahead and equal.
And I'm going to see my work.
Now let's go ahead and refresh this and check it out Steve Wall.
So you can see it two different ways I use to replace the first index.
So you can actually replace any index.
Maybe I want to replace index Nine.
So this guide on refreshes just TiVo P.
So just TiVo P.
All right.
So hope that is cool.
If you repressed index ten which is the character the space the skyline check it out.
We edit P right in between just TiVo Academy.
So instead of that space right in there what is in it.
Uh, that string, which is P right in there, that's character P, because everything is a character,
including a space is a character.
So one of I has been calculating how many characters you have in a string.
It always calculate even the space.
So this is all about string.
And uh, I hope that is really very cool.
So play around with them, try out more on these and uh, check out other resources.
And if you have any questions on these 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.