Hey!, now lets try learning a little bit more about “Strings” in PHP,
as you may or may not know, Strings are variables used to store “text”
data, however PHP have some functions that allow us to manipulate this
variables to acomplish certain tasks. Lets see some examples with
commonly used functions to handle strings.
Common functions to manipulate Strings
Most commonly used functions may includo explode(), implode(),
strlen() or strpos(), how ever on this file I’ll leave you simple
explanations for strlen and strpos, which are really basic functions to
learn, remember that handling strings correclty, will always come in
handy when developing programs, so that’s a pretty good reason to learn
how to use them.
the strlen() function
This function returns back the size of a String, the size is the same
number of characters included in the string variables, here is an
example.
the strpos() function
This functions returns the index position of an unique specified
character or phrase, that is contained within any string variable, for
example look at this code.
03 | $text = "hey everyone! this is my code!" ; |
06 | $position = strpos ( $text , 'everyone' ); |
Video tutorial for basic String functions
That’s all for now guys, thanks for cheking out the post, see ya later!!
Don’t forget to comment!