PHP string intercept function substr and Chinese intercept: mb_substr

time:17-07-07 forum:PHP tools and code
  The PHP string intercepts the function:

[code]string substr (string $string, int $start.#91; int $length) / > if it is non negative, the positive number is the first few, starting from 0.

if start is negative, the countdown number starts from -1.

if the length of string is less than or equal to start, it will return FALSE.
(Note: a function that PHP takes to intercept a string, can only handle English, numerals, can't intercept Chinese mixed rows)

[code]// constructs string
$str =.Quot; ABCDEFGHILMNOPQ.quot;
/ / / / > from fifth strings to last
$str1 = (5); / / / output ILMNOPQ

/ / / / / / / / / / / / / / / / / / / / / / / / = substr ($str, 9,4) from ninth characters; / / / / / output LMNO

5 characters
$str3 = substr. / / / / / output HIL


Chinese intercepting: mb_substr () $start, cut off the beginning, the beginning of the 0
$length, the number of words to be intercepted
$encoding, web code, such as UTF-8, GB2312, GBK

[code]
.lt; T; [/code]

prev:The queen of England has appointed the 1... next:June Ji'nan commercial housing network s...
post comment
Notice



approved   The "one school one product" sports ...   These "90" in the mountains, the vil...   Chinese girls spend 4 years designin...   Chongqing version of "peach sister":...   Returnees in mountainous areas suppo...
rand   Basic concept of character coding   PHP import and export of Excel file ...      PHP filter special characters and SQ...   PHP gets all the pictures in the web...
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com