Welcome to PHPMule.com
A blog site which I am posting to during my learning of the popular programming language PHP. Feel free to leave comments!
-
PHP - Finding Strings Within Strings
There are four functions you can use to find strings:
- strstr()
- strchr()
- strrchr()
- stristr()
The first function: strstr() can be used to find a string inside another or longer string for example:
if (strstr($string, ‘computer’))
echo “The word computer is found”;
This function is basically testing out whether or not the string ‘computer’ is in the variable $string. If the string is in variable $string it would output “The word computer is found” to the browser.
The second function we could use is strchr(). This function is the nearly similiar to the first function but this one finds a specific character such as ‘@’ or any other character.
The third function: strrchr() finds the last occurence of a character or string and then returns all the characters from that point onward. The last function is the stristr() function. This is the same as the strstr() function but it’s not case sensitive so you could find the string whether or not it’s in capitals or not (or both caps and not caps)
(Post created on Wednesday, April 15th 09 at 15:45)
-
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jun | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 | ||||
Archives
Recent Articles
- PHP - Rounding Off Numbers
- PHP - Single vs Double Quotation Marks
- PHP - Loading Files Into Your PHP Script By Using require() and include()
- PHP - Replacing Strings With Other Strings
- PHP - Finding Strings Within Strings
- PHP - Using strlen() To Test String Length
- PHP - Using The explode() Function
- PHP - Changing The String Case
- PHP - The nl2br() Function
- PHP - Trimming Strings
Links
Categories
- PHP (22)
- Uncategorized (1)


