We are usingResult: Array ([0] = 1 [1] = 2 [2] = 3 [3] = 4)
Definition and usage
The Str_split () function splits a string into an array.
Syntax length indicates the number of each string
Str_split (string,length) The default length is 1 above if it is Str_split ($STR, 2) result for array ([0] = [1] = 34)
If it is $str= ' 1 2 3 4 ' This time use explode () function explode (", $str) separated by spaces
If the content of an article is truncated by the number of characters: Use the strlen () function and the substr () string intercept function to implement the PHP split string function, such as:
- < ? PHP $ len = strlen ( $row [' Game_detail ']);
- //Gets the length of the string;
- if ($len 102)
- //judgment string if it is greater than 102, the output of 102 strings.
- {echo $ s = substr ($row [' Game_detail '],
0,102), echo ' ... ';
- }
- else{echo $row ["Game_detail"];
- //otherwise output all;
- }
- ?>< /span>
That is, make a judgment before the output. strlen (string name): substr (String, 0,102) the range to be divided by 0-103. These are all the methods of PHP split string, I hope you have some control.
http://www.bkjia.com/PHPjc/446237.html www.bkjia.com true http://www.bkjia.com/PHPjc/446237.html techarticle we are using the result: Array ([0] = 1 [1] = 2 [2] = 3 [3] = 4) define and use the Str_split () function to divide a string into an array. Syntax length indicates the number of each string ...