我有一個字符串看起來像這樣:
$str = "How are you doing?";
我怎樣才能把這個字符串到一個數組看起來像這樣:
$arr = array("Ho","w ","ar","r ","yo","u ","do","in","g?");
我有一個字符串看起來像這樣:
$str = "How are you doing?";
我怎樣才能把這個字符串到一個數組看起來像這樣:
$arr = array("Ho","w ","ar","r ","yo","u ","do","in","g?");
$array = str_split($str, 2);
看看str_split();它可以讓你通過字符的定義量來分割字符串,這樣你的代碼看起來像:
$arr = str_split($str, 2);
這將拆分$str
到一個數組$arr
,其中每個元素包含兩個字符,
我怎麼錯過那? :D謝謝! – JNK