PHP Encounters Chinese segmentation problem

Source: Internet
Author: User
$a = "A brigade of two brigade three brigade";
The string is the string that was previously processed, and the space is
Goal: Divide the string into three strings with a space.
We have tested n multiple empty line expressions, and can not use split split;
Also used the explode function is not implemented, please master to help solve it.
Requires a workaround for PHP.


Reply to discussion (solution)

$str = ' Jiangsu Nanjing Qixia District Taishan Street ';
echo $str. "
";
echo $param. "
"; Passed in the string a Brigade two brigade three brigade
$s = explode (' ', $str);
Print_r ($s);
echo "SS". $s [0]. " SS ";

Results page:
Jiangsu Nanjing Qixia District Taishan Street//$STR
A brigade of two brigade Three brigade//$param
Array ([0] = Jiangsu [1] = nanjing [2] = Qixia District [3] = Taishan Street) SS Jiangsu SS

can be divided into normal, switch to $s = explode (", $param);
The results page:
Jiangsu Nanjing Qixia District Taishan Street//$STR
A brigade of two brigade Three brigade//$param
Array ([0] = a brigade of two brigade three brigade) SS a brigade iron-making factory Iron Armour class SS

Hint: A brigade of two brigade Three Brigade//$param in the space for

Please God help to see how to correctly handle $param: A brigade of two brigade three brigade? Is this string swollen???? That's weird, huh?

$str = ' A brigade of two brigade Three brigade '; $arr =explode (", Str_replace (", ", $str));p Rint_r ($arr);//array ([0] = a brigade [1] = two Brigade [2] =&G T Three brigade)

The landlord is OK?

$string = "111 222 333"; Echo htmlspecialchars ($string);

Test it first.

$a  = "A brigade of two brigade three brigade"; $a = str_replace (', ', ', $a); $result = Explode (", $a); Echo '
 
   ; Echo '
';p rint_r ($result); Echo '
';


Array
(
[0] = a brigade
[1] = two Brigade
[2] = three Brigade
)
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.