WEBVTT

00:00.920 --> 00:03.980
I will call you back again to another lecture in PHP.

00:03.980 --> 00:09.650
And in this video lecture we go ahead and look at strings in PHP.

00:16.520 --> 00:17.000
All right.

00:17.000 --> 00:19.370
So we have always discussed about strings.

00:19.370 --> 00:23.480
And right now we go ahead and focus just on strings alone.

00:23.480 --> 00:26.960
So when we discuss about data types we talked about strings.

00:26.960 --> 00:30.590
And when we discuss about variables we also discussed about strings.

00:30.590 --> 00:34.250
Right now we are discussing about strings on its own.

00:34.250 --> 00:41.090
So string is very important because anything we put in between a quotation mark is a string.

00:41.120 --> 00:46.100
Now let's go ahead and say equal.

00:46.400 --> 00:52.400
And if we go ahead and say this is a J Steve.

00:53.810 --> 00:55.040
Oh I made a mistake.

00:55.040 --> 00:59.570
So this is a just war academy.

00:59.930 --> 01:00.260
All right.

01:00.260 --> 01:06.280
Now if you have this undiagnosed semicolon at the end and if I refresh this, you see how just simple

01:06.280 --> 01:09.640
academy this right inside that quotation mark.

01:09.640 --> 01:12.670
Just simple Academy is a string.

01:13.030 --> 01:19.570
So now we're going to look at different aspects of strings and what I'm, what I'm going to do or what

01:19.570 --> 01:22.660
this string ah function does in PHP.

01:22.990 --> 01:28.660
Now first of all I'm going to put this inside a a variable.

01:28.660 --> 01:31.000
So let's go ahead and create a variable.

01:31.000 --> 01:34.750
And I'm going to call that variable to be my wall.

01:36.070 --> 01:41.860
So let my wall be equal to.

01:45.310 --> 01:46.540
Guest wall.

01:50.080 --> 01:50.920
Academy.

01:51.310 --> 01:53.560
So my wall is equal to guest academy.

01:53.590 --> 01:55.450
Or put a semicolon at the end.

01:55.480 --> 02:05.850
Now if I want to echo this I will simply, simply say see my wall, then press semicolon at the end.

02:05.880 --> 02:07.320
Then we refresh this.

02:07.350 --> 02:10.140
We still have just the War Academy right in there.

02:10.500 --> 02:14.070
Now there are many things we can actually do.

02:14.100 --> 02:19.050
Maybe I want to make this just war academy to have everything go to in lower case.

02:19.080 --> 02:20.340
What am I going to do?

02:20.370 --> 02:22.830
I will go ahead and say echo.

02:22.860 --> 02:25.320
Then I'm going to copy everything right in here.

02:25.320 --> 02:29.670
And I'm going to say echo style.

02:29.700 --> 02:32.220
So anytime you use style this is a string.

02:32.220 --> 02:37.470
And I'll go ahead and say string to string to lower.

02:37.950 --> 02:42.090
Oh I want to remove this just string to lower.

02:42.090 --> 02:48.330
And then we go ahead and uh, list everything right inside there.

02:48.360 --> 02:53.220
Now a war had on refresh this and you can see that everything is in lowercase.

02:53.730 --> 02:59.760
Now you can actually go ahead and, uh, let's go ahead and copy everything we have right in here and

02:59.760 --> 03:02.540
go down here, and I'm going to do that for oppa.

03:02.570 --> 03:12.860
So if I do that for oppa, I'm going to change this from STL to lower to STL to oppa.

03:15.680 --> 03:19.850
So I'm going to save this and I'm going to refresh this I have I just save all.

03:19.850 --> 03:21.740
And the next one is just this one.

03:21.770 --> 03:22.310
All right.

03:22.310 --> 03:27.350
So because everything there is no brick stack tag day, there is no brick tag.

03:27.380 --> 03:29.180
That is why we have everything in one line.

03:29.180 --> 03:32.720
So let me go ahead and, uh, close this other one.

03:32.720 --> 03:36.230
And if I run this, I have just the academy right in here.

03:36.260 --> 03:38.600
So you can see that everything to oppa.

03:38.900 --> 03:47.300
Now what if what if I want to assess only just a wall without assessing academy?

03:48.140 --> 03:49.820
How can you be able to do that?

03:49.850 --> 03:53.300
Walter says only just ignore that assistant academy.

03:53.300 --> 03:57.200
Or maybe you assess only academy without just wall.

03:57.290 --> 03:59.810
No, I will go ahead and, uh.

04:01.390 --> 04:03.790
let's go ahead and echo this out.

04:03.790 --> 04:06.520
So I want to say echo.

04:06.670 --> 04:13.180
And then we go ahead and, uh, create what is called a substring.

04:13.180 --> 04:18.700
So in that case, I want to collect just a portion of a string.

04:18.700 --> 04:21.880
That means I'm collecting a substring right in here.

04:21.910 --> 04:23.830
So I'm going to say so.

04:24.190 --> 04:26.440
And then you add string.

04:26.470 --> 04:28.690
This is a substring in PHP.

04:28.750 --> 04:37.030
And now I'll go ahead and uh input my variable which is my wall.

04:37.060 --> 04:39.130
Then I have to count these.

04:39.160 --> 04:40.510
The first one here is

04:40.510 --> 04:47.500
0123456789

04:47.500 --> 04:48.430
1011.

04:48.460 --> 04:50.830
That means I'm going to start from a.

04:50.860 --> 04:53.200
So I'll go ahead and put 11.

04:53.230 --> 04:55.090
Then put a semicolon at the end.

04:55.090 --> 04:57.940
And let's refresh this academy.

04:58.360 --> 05:04.710
So you can see I was able to get a portion of that strain, which is called a substring, and that is

05:04.740 --> 05:05.370
academy.

05:05.370 --> 05:06.780
So is that academy.

05:06.810 --> 05:14.940
Maybe I want to start from I just want to take only a C, a D, let's say acad.

05:14.970 --> 05:22.350
So that is I'm going to say this started from four.

05:22.380 --> 05:29.520
And if I save this out of fresh I have a cat because I just need only this first four right in here.

05:30.330 --> 05:37.950
Now this is about substring how to, you know, collect some portion of your string.

05:37.980 --> 05:40.740
I'll go ahead and show us another one.

05:40.830 --> 05:44.160
What if you want to calculate the length of this string?

05:44.190 --> 05:51.420
Everything right in the sky let's say echo then STL length.

05:51.450 --> 05:58.560
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.

05:58.560 --> 06:01.400
And let's go here, refresh this and check it out.

06:01.400 --> 06:05.480
So it means it is 18 characters that are right in here.

06:05.480 --> 06:08.810
So we have 18 characters right in there.

06:09.500 --> 06:18.050
So you use the SQL Len to be able to check out how many characters you have in a string.

06:18.710 --> 06:24.410
So what if what if I want to get maybe only G.

06:24.650 --> 06:28.940
So anytime you're working with a string, I want us to note this.

06:28.970 --> 06:31.580
The first character I have here is zero.

06:31.610 --> 06:42.290
Next one is next one is one, two, three, four, five, six, seven, eight, nine and so on to 18.

06:42.290 --> 06:44.420
So the very first one is zero.

06:44.450 --> 06:45.590
Now let's go ahead.

06:45.590 --> 06:51.230
And uh, I'm going to comment on this so that it will always be here.

06:52.970 --> 06:54.500
So our first one is zero.

06:54.500 --> 06:59.030
And uh let's go ahead and check it out to make sure we have it.

06:59.030 --> 07:09.280
So echo and I will go ahead and input in my variable my wall.

07:09.670 --> 07:13.900
And then I'm going to pass the index zero of that.

07:13.900 --> 07:21.010
If I pass in index zero then I go ahead and print out only the first one.

07:21.040 --> 07:22.900
Or first is I check it out G.

07:23.560 --> 07:29.410
So you can see I'm able to get G, because that is a first one right in there.

07:29.440 --> 07:37.300
So if I go over here and input one, I refresh and half as a s.

07:37.330 --> 07:42.730
Now remember we input 11 and a got academy.

07:42.760 --> 07:48.310
So if I go back right here and put 11 I'm going to get just a correct out is a refresh.

07:48.310 --> 07:50.320
And that is what we have right in here.

07:50.770 --> 07:56.200
So I believe that this is really making sense to us because we need to know all this.

07:56.230 --> 07:59.700
It helps us in our day to day execution of our programs.

08:00.570 --> 08:03.480
Now there is another wall right in here.

08:03.750 --> 08:07.320
What if I want to change?

08:07.320 --> 08:09.750
Just wall to wall Academy.

08:09.780 --> 08:11.280
To my academy?

08:11.430 --> 08:16.440
Then I will go ahead and use what is called a string replace.

08:16.440 --> 08:23.790
So go ahead and say echo zero underscore replace.

08:24.180 --> 08:31.500
And now I want to be able to replace this wall with moi.

08:31.530 --> 08:36.600
Now I'm going to pass in the first one which is a DST wall.

08:36.990 --> 08:43.110
Then the next argument or the next parameter I'm going to put in here is going to be what you want to

08:43.140 --> 08:46.740
use to replace that first one, which is just a wall.

08:46.770 --> 08:48.840
So that is moi.

08:48.990 --> 08:59.360
And then I'll go ahead and pass in my variable name, which is uh, my wall, because that is the string.

08:59.360 --> 09:01.730
I want this to be executed off.

09:01.730 --> 09:04.490
So go ahead and save this and let's refresh this.

09:04.700 --> 09:05.360
And then what?

09:05.390 --> 09:13.280
Academy are no longer just a war academy, so I hope that is really making sense.

09:13.310 --> 09:16.160
That is really making sense.

09:16.160 --> 09:18.380
So that is really very interesting.

09:18.770 --> 09:25.520
So I believe that everything we are doing right in here is actually making sense to us.

09:25.520 --> 09:32.840
And uh, I believe that, uh, with time, you're going to master everything.

09:32.870 --> 09:44.870
Let me say I want to replace let's say I want to have my I'll go ahead and delete this and save.

09:44.870 --> 09:53.030
And let's refresh this just for a memoir Academy, because I just want to replace only this portion,

09:54.620 --> 09:55.430
you understand?

09:55.460 --> 09:58.100
I want to replace just this portion alone.

09:58.510 --> 10:03.100
So I've replaced the wall with suggestive Memoir Academy.

10:03.190 --> 10:07.510
So if you put everything you have a pleasant everything right in there.

10:07.570 --> 10:09.160
Everything right in there.

10:10.180 --> 10:14.410
Okay, so what if you just wanted a place?

10:14.440 --> 10:19.210
Let me say a half wall, and I want to call this.

10:19.240 --> 10:20.740
Let's go ahead and remove this.

10:20.770 --> 10:24.040
And I want to the place let me say G.

10:26.170 --> 10:29.650
With e let's go ahead and save our refresh.

10:29.680 --> 10:34.150
And we have Estival Academy and no longer Festival Academy.

10:34.150 --> 10:35.980
So we have still four.

10:36.010 --> 10:39.220
Academy because I just want to replace only the G.

10:40.990 --> 10:41.740
You understand?

10:41.740 --> 10:43.990
So I hope that is really very cool.

10:44.350 --> 10:47.590
Now there is one more thing I'm going to show us before we run out.

10:47.620 --> 10:54.790
So when I talked about, uh, the index, you kind of press an index.

10:54.820 --> 10:56.290
Let me say, without.

10:56.320 --> 10:58.800
Going this way, there is something I got to do.

10:58.830 --> 11:04.980
Let me say I have a couple of days, and then I'm going to.

11:05.640 --> 11:06.090
Okay.

11:06.120 --> 11:11.700
Number four, start with a my variable name, which is my.

11:11.700 --> 11:12.330
Whoa.

11:12.330 --> 11:17.970
And then I'm going to pass in in the index I want to replace index zero now.

11:17.970 --> 11:19.590
And that index zero is G.

11:19.680 --> 11:23.880
And then I'll go ahead and say this is equal to.

11:24.450 --> 11:26.220
In the first one I use a e.

11:26.250 --> 11:34.200
Let me go ahead and say I'm going to use um p and then put a semicolon at the end.

11:34.200 --> 11:37.440
And now let's go ahead and equal.

11:38.280 --> 11:44.010
And I'm going to see my work.

11:44.220 --> 11:48.660
Now let's go ahead and refresh this and check it out Steve Wall.

11:49.140 --> 11:53.250
So you can see it two different ways I use to replace the first index.

11:53.250 --> 11:55.560
So you can actually replace any index.

11:55.560 --> 11:58.070
Maybe I want to replace index Nine.

11:58.700 --> 12:02.060
So this guide on refreshes just TiVo P.

12:03.110 --> 12:05.030
So just TiVo P.

12:05.510 --> 12:06.080
All right.

12:06.080 --> 12:07.520
So hope that is cool.

12:07.910 --> 12:12.890
If you repressed index ten which is the character the space the skyline check it out.

12:12.920 --> 12:15.830
We edit P right in between just TiVo Academy.

12:15.830 --> 12:18.890
So instead of that space right in there what is in it.

12:19.280 --> 12:26.630
Uh, that string, which is P right in there, that's character P, because everything is a character,

12:26.660 --> 12:28.250
including a space is a character.

12:28.250 --> 12:31.940
So one of I has been calculating how many characters you have in a string.

12:31.940 --> 12:34.580
It always calculate even the space.

12:34.760 --> 12:37.220
So this is all about string.

12:37.220 --> 12:40.700
And uh, I hope that is really very cool.

12:40.700 --> 12:46.550
So play around with them, try out more on these and uh, check out other resources.

12:46.550 --> 12:51.500
And if you have any questions on these please use the question and answer section.

12:51.500 --> 12:54.170
And I'm going to get back to you as soon as possible.

12:54.170 --> 12:55.130
Thank you so much.

12:55.130 --> 12:58.310
And I'm going to see you in the next video lecture.
