With the development of the Times, our development technology also with the update, for PHP or more commonly used, so I studied the PHP array to the string, here to take out and share with you, hope to be useful to everyone.
It is often necessary to use PHP to handle characters string,php built-in character functions that provide a very powerful function that basically completes most character processing operations. If you use the Str_split function to convert a character to an array, the IMPLODE function converts the PHP array to a string, the Strpos function looks for another character in one character, the substr function gets a few characters in the character, the strlen function gets the character length, and so on. These are the most basic knowledge of PHP, convenient for daily use, I will do some summary of this function, for reference only.
1, how to convert a character to an array
Workaround: Str_split () function
Examples are as follows:
- $ biuuu ' www.biuuu.com ';
- Print_r (Str_split ($BIUUU))
Output Result:
- Array
- (
- [0] => b
- [1] => i
- [2] => u
- [3] => u
- [4] => u
2, how to convert a PHP array to a string
Workaround: Implode () function
Examples are as follows:
- $ biuuu Array(' B ', ' I ', ' u ', ' u ', ' U ');
Output result Biiuu
3, how to find another character in one character
Workaround: Strpos or Strstr
Examples are as follows:
- $ biuuu ' This is my website biuuu.com ';
- $ Search ' biuuu ';
Output results: 19
4, how to get a few characters in a character
Workaround: substr () function
Examples are as follows:
- $ biuuu ' This is my website biuuu.com ';
Output Result: biuuu.com
5, how to get the character length
Workaround: strlen () function
Examples are as follows:
- $ biuuu ' This is my website biuuu.com ';
Output Results 28
The above several PHP character processing functions str_split, implode, Strpos, substr and strlen in the actual development because often need to use, hope to be helpful to everybody.
http://www.bkjia.com/PHPjc/446527.html www.bkjia.com true http://www.bkjia.com/PHPjc/446527.html techarticle with the development of the Times, our development technology also with the update, for PHP or more commonly used, so I studied the PHP array to string, here to take out and share with you ...