PHP String Functions

Functions Description
addcslasher()Add slashes to chars
chop()Remove blank space at the end of the string
chunk_split()Break string after a position
chr()Print ASCII characters
count_chars()Details about the string
explode()Breaking string using delimiter
fgetcsv()Getting data from CSV file
fputcsv()Writing data to a CSV file
htmlspecialchars()Converting HTML chars
implode()Joining elements of an array
lcfirst()First char to lower case
preg_replace()regular expression string replacement
md5()String encryption
nl2br()Converting Line breaks to HTML <BR> tags
ord()Get ASCII value of any character
password_hash()One way password hash
password_verify()Matching string with password hash
strip_tags()Removing HTML tags from string & keeping text part
str_replace()Case sensitive string replacement
str_ireplace()Case in-sensitive string replacement
substr_count()Counting presence of sub-string inside a main string
str_repeat()Repeating string
str_shuffle()Shuffle a string
str_split()split a string with fixed intervals ( without using any delimiter )
str_word_count()Counting Words in a string
random_bytes()cryptographically secure random bytes ( PHP 7 )
strrev()Reversing a string
strlen()Length of a string
strstr()Searching string with needle ( Case sensitive )
stristr()Searching string with needle ( Case in-sensitive )
split()Breaking string using delimiter
substr()Part of the string with length and position
strtolower()Changing all upper case char to lower case
strtoupper()Changing all lower case char to Upper case
strcasecmp()case in-sensitive string comparison
strcmp()case sensitive string comparison
str_pad()Padding string from left , right or both sides
trim()Removing char or blank space from left , right and both sides of a string
ucwords()Change to upper case for each first char of all the words of a string
ucfirst()Change to upper case for first char of a string
wordwrap()Wrapping the string after a width
  • strpos() case-sensitive search returns position of first occurrence
  • stripos() case-insensitive search returns position of first occurrence
  • strrpos() case-sensitive search returns position of last occurrence
  • strripos() case-insensitive search returns position of last occurrence

Scripts using String functions in PHP

Palindrome
Check the input string is Palindrome or not

ctype_lower() & ctype_upper()
checking presence of lower or upper case letter only.

Checking String
Checking string for presence of Upper case or lower case letter or special characters or space.

Random string
We can generate random string by using rand function

Removing chars from end
Remove chars from end of the string by using length and sub string functions

Adding strings
Add two or more strings including date.

Collecting part of string
Extracting string part using two landmark points

Email part
Getting the domain and Userid part from an email address

Questions


Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    satish

    13-03-2013

    Its good information

    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer