PHP string manipulation

explode  —  use one string to split another string 

array explode ( string $delimiter , string $string [, int $limit ] )

implode  —  converts a one-dimensional array of values ​​to a string

string implode ( string $glue , array $pieces )

htmlspecialchars  —  Convert special characters to HTML entities (XXS)

string htmlspecialchars ( string $string )

htmlspecialchars_decode  —  converts special HTML entities back to normal characters (as opposed to htmlspecialchars)

string htmlspecialchars_decode ( string $string )

strip_tags  —  strips HTML and PHP tags from strings (unlike htmlspecialchars, strip_tags strips tags directly, while the former escapes them to other characters) 

string strip_tags ( string $str [, string $allowable_tags ] )

md5  —  Calculates the MD5 hash of a string

string md5 ( string $str [, bool $raw_output = false ] )

nl2br  —  inserts HTML newlines before all newlines in the string (converts \n or \r\n not recognized by browsers to </br>)

string nl2br ( string $string [, bool $is_xhtml = TRUE ] )

trim  —  remove whitespace (or other characters) at the beginning and end of a string

string trim ( string $str [, string $character_mask = " \t\n\r\0\x0B" ] )

strpos  —  find the first occurrence of a string ( stripos is not case sensitive) ( usually used to tell if a string contains another string )

 

int stripos ( string $haystack , string $needle [, int $offset = 0 ] )

strrpos  —  Calculates the position of the last occurrence of the specified string in the target string

int strrpos ( string $haystack , string $needle [, int $offset = 0 ] )

strlen  —  get the length of the string (can also be used to determine whether the string is empty)

int strlen ( string $string )

strtolower  —  converts a string to lowercase

string strtolower ( string $string )

strtoupper  —  convert a string to uppercase

string strtoupper ( string $string )

substr_count  —  count the number of occurrences of a string

int substr_count ( string $haystack , string $needle [, int $offset = 0 [, int $length ]] )

substr  —  returns a substring of the string (returns the substring of the string  specified string by  the start and  lenth parameters)

string substr ( string $string , int $start [, int $length ] )

string

Enter a string. Must have at least one character.

start

If  start non-negative, the returned string will  start string at  start position 0, counting from 0. For example, in the string " abcdef ", the character in position  0  is " a ", the character in position  2  is " c ", and so on.

If  start negative, the returned string will  start string at the first character from the end  start .

Will return  if  string the length is less than  .startFALSE

length

If a positive number is provided  length, the returned string will be  start up to and including  length characters (depending on  string the length) starting at .

If a negative number is provided  length, the  characters string at the end  length will be omitted ( start if negative number is counted from the end of the string). If  start not in this text, it will return  FALSE.

If a value of  0 , FALSE or  NULL , is provided  length, then an empty string will be returned.

If not provided  length, the returned substring will  start start at position until the end of the string.

 

str_replace  —  Substring replacement (use  str_ireplace ignoring case )

mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

search

The target value of the lookup, which is the  needle . An array can specify multiple targets.

replace

search replacement value. An array can be used to specify multiple replacements.

subject

Array or string to perform the replacement on. That is  haystack .

If it  subject is an array, the replace operation will traverse the whole  subjectand the return value will also be an array.

count

If specified, its value will be set to the number of times the replacement occurred.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325937742&siteId=291194637