国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Is there any easy way to break a string into a character array in php?
伊謝爾倫
伊謝爾倫 2017-06-21 10:11:28
0
10
1238

For example, I want to turn $str = 'adfdf' into an array like ['a', 'd', 'f', 'd', 'f']

伊謝爾倫
伊謝爾倫

小伙看你根骨奇佳,潛力無(wú)限,來(lái)學(xué)PHP伐。

reply all(10)
洪濤

I found that I can use the function str_split

曾經(jīng)蠟筆沒(méi)有小新

I have done string comparison before using the lcs algorithm, which involves breaking up strings into arrays. Due to Chinese issues, it is not possible to use str_split directly. You need to use preg_split

你可以封裝一個(gè)公共函數(shù)

function mb_str_split($str)
{
    return preg_split('/(?<!^)(?!$)/u' , $str);
}
我想大聲告訴你
$string = '中國(guó)共產(chǎn)黨萬(wàn)歲!aaaaa';
var_dump(preg_split('//u', $string, 0, PREG_SPLIT_NO_EMPTY));
/*
array (size=13)
  0 => string '中' (length=3)
  1 => string '國(guó)' (length=3)
  2 => string '共' (length=3)
  3 => string '產(chǎn)' (length=3)
  4 => string '黨' (length=3)
  5 => string '萬(wàn)' (length=3)
  6 => string '歲' (length=3)
  7 => string '!' (length=3)
  8 => string 'a' (length=1)
  9 => string 'a' (length=1)
  10 => string 'a' (length=1)
  11 => string 'a' (length=1)
  12 => string 'a' (length=1)
 */
滿天的星座
preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
扔個(gè)三星炸死你

The string itself can be used as an array
$str = "abcdef";
You output $str[0].$str[1].$str[2];
You will find that it is actually $str
array(" a","b","c","d","e","f");

學(xué)習(xí)ing
$str = 'adfdf';
$arr = [];
for($i=0;$i<strlen($str);$i++) {
$arr[$i] = $str{$i};
}

var_dump($arr);
$str = 'adfdf';
preg_match_all('/(\w{1})/', $str, $matches);
var_dump($matches[0]);
phpcn_u1582
$str = 'adfdf';
$temp = array();
for ($i = 0; $i < strlen($str); $i++) {
    array_push($temp, $str{$i});
}
var_dump($temp);
巴扎黑

$str = 'adfdf';

    $len = mb_strlen($str);
    $arr = [];
    if(!isset($str[0])) {
        exit('輸入合理字符串!');
    }
    $rb = function ($index = 0) use (&$rb, &$arr, $str, $len) {
         array_push($arr, mb_substr($str, $index, 1,'UTF-8'));
        $index++;
        if ($index == $len) return $arr;
        $rb($index);
    };
    $rb();
    header("Content-type: text/html; charset=UTF-8");
   var_dump($arr);
代言
<?php
$str = 'adfdf';
$arr = array();
for($i=0;$i<strlen($str);$i++) {
$arr[$i] = $str[$i];
}
print_r($arr);
?>
迷茫

explode doesn’t work?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template