Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the classifications of PHP string functions

Shulou Source: shulou.com Published: 2022-06-03 19:03:35 10月15日 Update

This article introduces the relevant knowledge of "what are the classifications of PHP string functions". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Strpos returns the position of string An in string B (the result is a number)

The opposite PHP string function is that strrpos returns the position of string An in string B (the result is a number).

Addcslashes prepends a backslash "\" to the specified character, such as echo addcslashes ($string, "YMagol O"); / / adds a backslash "\" to the specified character "Ymai O".

Addslashes prepends a specific character in a string with a backslash "\" special character refers to single quotation mark, double quotation mark, null and backslash "\"

Strstr gets the substring from the position where the specified string An appears in string B to the end of string B.

Strrchr gets the substring from the position where the specified string An appears once 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" = > "Ming", "1" = > "day"); array_push ($array, "technology")

Print_r ($array); the running result is array ([0] = > Ming [1] = > Japan [2] = > Science and Technology)

In contrast, the PHP string function is used by array_unshift to increase the specified numeric value to the beginning of the array.

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

The array_unique function removes duplicate values from the specified array and returns a new array.

The array_merge function is used to combine multiple numbers together and return a new array.

The array_slice function is used to extract array elements of specified length from a specified location of the array, and save the extracted elements to a new array, such as $array=array ("I", "yes", "Hu", "rain", "Xuan").

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

The value of $array1 is "Hu Yuxuan"

The PHP string function, by contrast, is used by the array_splice function to delete array elements that start at a specified location in the array and save the deleted elements to a new array.

This is the end of the content of "what are the classifications of PHP string functions". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Characters strings functions arrays positions elements slashes endings results categories content quotes numeric values numbers more knowledge science and technology and will practical special Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS MariaDB Shulou Information vpn