Maison > Article > développement back-end > 请问用哪个字符串函数截取下面字符串最后两项并转换为数组?
请问用哪个函数将下面的字符串截取后面两项并转换为数组?
$week = "Monday,Tuesday,Wednesay,Thursday,Friday,Saturday,Sunday";
?>
请问用哪个函数将下面的字符串截取后面两项并转换为数组?
$week = "Monday,Tuesday,Wednesay,Thursday,Friday,Saturday,Sunday";
?>
<code>$result = array_splice( explode(',', $week), -2 ); var_dump($result);</code>
先分割成数组 然后用array_splice取数组的后两个元素