ankitweblogic logo
W e b t u t o r i a l s

Define PHP

PHP Installation


PHP Case Sensitivity

PHP Variable

PHP Echo & Print

PHP Operators

PHP Receiving Input

PHP Decision Making

PHP Loops

PHP Jumping Statement

PHP Image Gallery

PHP Arrays

PHP Date Functions

PHP String Functions

PHP Math Functions

PHP Functions

PHP Variable Scope

PHP Constant Variable

PHP Superglobals

PHP Form Validation

PHP Include Statement

PHP Filter

PHP File Handling

PHP File Upload

PHP Cookies

PHP Session

PHP Send Emails

PHP Captcha

PHP-MySQL Connectivity

PHP MySQL Select

PHP MySQL Insert

PHP MySQL Delete

PHP MySQL Update

PHP String Functions

Strings are the collection of Characters. Common Built-in PHP String Functions are:

Function Description
strlen() The PHP strlen() function returns the length of a string.
Syntax: echo strlen("Hello world!");
str_word_count() The PHP str_word_count() function counts the number of words in a string:
Syntax: echo str_word_count("Hello world!");
strrev() Reverses a string
Syntax: echo strrev("Hello world!");
strpos() Searches for a specific text within a string. If a match is found, the function returns the character position of the first match. If no match is found, it will return FALSE.
Syntax: echo strpos("Hello world!", "world");
str_replace() Replaces some characters with some other characters in a string.
Syntax: echo str_replace("world", "Dolly", "Hello world!");
strchr() Searches for the first occurrence of a string inside another string.
Syntax: echo strchr("Hello world!","world");
strcmp() Compare two strings (case-sensitive):
Syntax: echo strcmp("Hello world!","Hello world!");
strcasecmp() Compares two strings (case-insensitive)
strncmp() String comparison of the first n characters (case-sensitive)
strtolower() Converts a string to lowercase letters
strtoupper() Converts a string to uppercase letters
str_shuffle() Shuffles all characters in a string Randomly.
str_repeat() Repeats a string upto specified number of times.
substr() Returns a part of a string.
trim() Removes whitespace or other characters from both sides of a string
ucfirst() Converts the first character of a string to uppercase
ucwords() Converts the first character of each word in a string to uppercase
wordwrap() Wraps a string to a given number of characters