Okay, now let's see.
How can we manipulate the strings?
Let me define a variable and just type hello comma world.
Something like this.
And now how can we access individual characters from the string?
Well, same as with the array.
We just use the square bracket syntax.
So let's see what this would give us.
This zero.
This should give us the first character.
Let me run PHP string manipulation.
There it is.
We've got H.
So using this square bracket syntax you can get specific characters same as in the array.
You can get specific elements from the array.
Next up you can also use negative indexes.
So with this str variable if I output minus one I wonder if you can guess what we're gonna get here.
So let me type that.
And you see this.
The exclamation mark.
So minus one means indexing characters from the end of the string.
So this one.
All right.
Next up, what if you'd like to just grab a part of the string?
Not one character, but maybe a specific amount of characters starting at a specific index.
So there is a function for this called substr.
And you pass a string there.
The starting index.
Um, this starts with zero.
And then optionally the length of characters you want to grab.
If you skip the length.
Everything starting from index will be returned.
So with this string starting from index zero getting five characters, let's see what we're gonna get.
Um, maybe I'm gonna comment out those first.
Let's see.
Um, well, that's.
Hello.
First five characters.
Now, if we're gonna start at index five instead, and we skip the length, well, we're gonna get the
remainder of this string.
So if I comment out this line that's the result of that line.
Now another thing we can do is we can modify the case of the strings.
So str to upper I think we've used this function before.
This will just convert every single character to uppercase like that.
And str to lower will do the opposite.
It will convert everything to lowercase.
Let me comment out those so we can clearly see the output.
There it is.
That was the original.
So if we want to uppercase only the first character we can do you see first.
And if we mix that with str two lower we can only make the first character of the sentence uppercase.
That's also often very useful.
So essentially it looks like this.
Typically you just start a sentence from the uppercase letter.
So this combination is something you actually might be using quite often.
Next up the concatenation.
Let's define a greeting variable that might say hello.
And we've seen that before.
So we use dot operator to concatenate.
I forgot the assignment.
So that's a typical concatenation.
Nothing we haven't done before.
But apart from this you can append something.
So this will be dot equals.
This just means append some text to the variable on the left.
So this would be let's say how are you.
Now let's echo this greeting variable.
So this is PHP string manipulation.
And there we have it.