131 0

Rt finds a function that's intercepted in both chinese and english strings, mb_substr ( ), ( ), iconv_substr ( ), and the custom functions that have been placed on the web!
In fact, my main purpose is to cut out the length of the words that are identical, so please try ~.

Here's the code I tested, which looks like the first and second answers that come with a code of code that says ~.
Ps: answer the question with my part test small text test, and then pass the answer to ~.

$one = '20';
$text = 'Nokia阿根廷部门开发了Angry Birds和Fruit Ninja书签工具,通过此书签玩家就可以在任何网站裡开启Angry Birds和Fruit Ninja畅玩,而且你发射的小鸟会破坏网页架构,你切水果的手势也会顺便把网站大卸八块。';
$count= mb_strlen($text);
$row = ($count - $count%$one)/$one;
if($count%$one!= 0) {
$row = $row+1; 
for($i=0;$i <$row;$i++) {
echo mb_strimwidth($text, $i*$one, $one);
echo '<br/>';
2 Answers

51 2

I want you to mb_strimwidth this function, to look at its definition, http://cn2, php, net/manual/en/function.

111 0

I used a scheme. Assuming that your string is utf, then you need to convert it to.

$gbk_str = iconv('UTF-8', 'GBK', $raw);

It then takes the $ gbk_str, the gbk character is two bytes, and the english is one, so it's just right.