用PHP中其他字符串的长度连续拆分字符串?

时间:2017-01-06 19:34:29

标签: php

如何根据第二个变量

的长度拆分下面的第一个文本变量
$text = "hey how are you";
$text1 = "how are you";
$length = strlen($text);
$length1 = strlen($text1);

1 个答案:

答案 0 :(得分:0)

使用str_split

$text = "hey how are you";
$text1 = "how are you";
$length = strlen($text);
$length1 = strlen($text1);
$parts = str_split($text, $length1); 
// Array([0] => hey how are [1] =>  you)