0

PHP String Functions

Posted by Jujur Sitanggang on 5:52 AM

PHP String Functions


PHP String Introduction

The string functions allow you to manipulate strings.

Installation

The string functions are part of the PHP core. There is no installation needed to use these functions.

PHP String Functions

PHP: indicates the earliest version of PHP that supports the function.
Function
Description
PHP
Returns a string with backslashes in front of the specified characters
4
Returns a string with backslashes in front of predefined characters
3
Converts a string of ASCII characters to hexadecimal values
3
Alias of rtrim()
3
Returns a character from a specified ASCII value
3
Splits a string into a series of smaller parts
3
Converts a string from one Cyrillic character-set to another
3
Decodes a uuencoded string
5
Encodes a string using the uuencode algorithm
5
Returns how many times an ASCII character occurs within a string and returns the information
4
Calculates a 32-bit CRC for a string
4
One-way string encryption (hashing)
3
Outputs strings
3
Breaks a string into an array
3
Writes a formatted string to a specified output stream
5
Returns the translation table used by htmlspecialchars() and htmlentities()
4
Converts Hebrew text to visual text
3
Converts Hebrew text to visual text and new lines (\n) into <br />
3
Converts HTML entities to characters
4
Converts characters to HTML entities
3
Converts some predefined HTML entities to characters
5
Converts some predefined characters to HTML entities
3
Returns a string from the elements of an array
3
Alias of implode()
3
Returns the Levenshtein distance between two strings
3
Returns locale numeric and monetary formatting information
4
Strips whitespace from the left side of a string
3
Calculates the MD5 hash of a string
3
Calculates the MD5 hash of a file
4
Calculates the metaphone key of a string
4
Returns a string formatted as a currency string
4
Returns specific local information
4
Inserts HTML line breaks in front of each newline in a string
3
Formats a number with grouped thousands
3
Returns the ASCII value of the first character of a string
3
Parses a query string into variables
3
Outputs a string
3
Outputs a formatted string
3
Decodes a quoted-printable string
3
Quotes meta characters
3
Strips whitespace from the right side of a string
3
Sets locale information
3
Calculates the SHA-1 hash of a string
4
Calculates the SHA-1 hash of a file
4
Calculates the similarity between two strings
3
Calculates the soundex key of a string
3
Writes a formatted string to a variable
3
Parses input from a string according to a format
4
Replaces some characters in a string (case-insensitive)
5
Pads a string to a new length
4
Repeats a string a specified number of times
4
Replaces some characters in a string (case-sensitive)
3
Performs the ROT13 encoding on a string
4
Randomly shuffles all characters in a string
4
Splits a string into an array
5
Count the number of words in a string
4
Compares two strings (case-insensitive)
3
Finds the first occurrence of a string inside another string (alias of strstr())
3
Compares two strings (case-sensitive)
3
Locale based string comparison
4
Returns the number of characters found in a string before any part of some specified characters are found
3
Strips HTML and PHP tags from a string
3
Unquotes a string quoted with addcslashes()
4
Unquotes a string quoted with addslashes()
3
Returns the position of the first occurrence of a string inside another string (case-insensitive)
5
Finds the first occurrence of a string inside another string (case-insensitive)
3
Returns the length of a string
3
Compares two strings using a "natural order" algorithm (case-insensitive)
4
Compares two strings using a "natural order" algorithm (case-sensitive)
4
String comparison of the first n characters (case-insensitive)
4
String comparison of the first n characters (case-sensitive)
4
Searches a string for any of a set of characters
5
Returns the position of the first occurrence of a string inside another string (case-sensitive)
3
Finds the last occurrence of a string inside another string
3
Reverses a string
3
Finds the position of the last occurrence of a string inside another string (case-insensitive)
5
Finds the position of the last occurrence of a string inside another string (case-sensitive)
3
Returns the number of characters found in a string that contains only characters from a specified charlist
3
Finds the first occurrence of a string inside another string (case-sensitive)
3
Splits a string into smaller strings
3
Converts a string to lowercase letters
3
Converts a string to uppercase letters
3
Translates certain characters in a string
3
Returns a part of a string
3
Compares two strings from a specified start position (binary safe and optionally case-sensitive)
5
Counts the number of times a substring occurs in a string
4
Replaces a part of a string with another string
4
Strips whitespace from both sides of a string
3
Converts the first character of a string to uppercase
3
Converts the first character of each word in a string to uppercase
3
Writes a formatted string to a specified output stream
5
Outputs a formatted string
4
Writes a formatted string to a variable
4
Wraps a string to a given number of characters
4


PHP String Constants

PHP: indicates the earliest version of PHP that supports the constant.
Constant
Description
PHP
CRYPT_SALT_LENGTH
Contains the length of the default encryption method for the
system. For standard DES encryption, the length is 2

CRYPT_STD_DES
Set to 1 if the standard DES-based encryption with a 2 character salt is supported, 0 otherwise

CRYPT_EXT_DES
Set to 1 if the extended DES-based encryption with a 9 character salt is supported, 0 otherwise

CRYPT_MD5
Set to 1 if the MD5 encryption with a 12 character salt starting with $1$ is supported, 0 otherwise

CRYPT_BLOWFISH
Set to 1 if the Blowfish encryption with a 16 character salt starting with $2$ or $2a$ is supported, 0 otherwise0

HTML_SPECIALCHARS


HTML_ENTITIES


ENT_COMPAT


ENT_QUOTES


ENT_NOQUOTES


CHAR_MAX


LC_CTYPE


LC_NUMERIC


LC_TIME


LC_COLLATE


LC_MONETARY


LC_ALL


LC_MESSAGES


STR_PAD_LEFT


STR_PAD_RIGHT


STR_PAD_BOTH






0 Comments

Copyright Jujur Soaloon Sitangang Lipan All rights reserved. Theme by Sitanggang. | Bloggerized by Soalparna.