Home  >  Article  >  Backend Development  >  Classification summary of PHP string functions_PHP tutorial

Classification summary of PHP string functions_PHP tutorial

WBOY
WBOYOriginal
2016-07-15 13:31:12992browse

strpos returns the position of the first occurrence of string A in string B (the return result is a number)

The opposite PHP string function is strrpos returns the character The last position of string A in string B (the return result is a number)

addcslashes adds a backslash "" before the specified character. For example, echo addcslashes($string," Y,O"); //Add backslash "" before the specified character "Y,O"

addslashes Add backslash "" before specific characters in the string Special characters refer to single Quotation marks, double quotes, null and backslash ""

strstr Gets the substring from the first occurrence of the specified string A in string B to the end of string B

strrchr Gets the substring from the last occurrence of the specified string A in string B to the end of string B

The array_push function is used to increase the specified value to the end of the array $array=array("0"=>"明","1"=>"日"); array_push($array,"Technology");

print_r($array ; The value is increased to the starting position of the array

The array_pop function returns the last element of an array. The opposite function is the array_shift function, which returns the first element of an array

array_unique function is used to remove duplicate values ​​in the specified array and returns a new array

array_merge function is used to merge multiple arrays together and return a new Array

The array_slice function is used to extract array elements of a specified length starting from a specified position in the array, and save the extracted elements to a new array, for example $array=array(" I","Yes","Hu","Yu","Xuan");

$array1=array_slice($array,2,3);

The value of $array1 is "Hu Yuxuan"

The opposite PHP string function is the array_splice function, which is used to delete a specified number of array elements starting from a specified position in the array, and save the deleted elements to a new array


http://www.bkjia.com/PHPjc/446233.html

truehttp: //www.bkjia.com/PHPjc/446233.htmlTechArticlestrpos returns the position where string A first appears in string B (the return result is a number). On the contrary The PHP string function strrpos returns the last occurrence of string A in string B...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn