如何拆分PHP变量

Jas*_*uni -2 php

我正在寻找一种方法将字符串变量拆分为两个.举个例子,如果我有:

$activities = "In the morning we will dance, in the evening we will sing"
Run Code Online (Sandbox Code Playgroud)

我想把它拆分成,

$activities1 = "In the morning we will dance"
$activities2 = "In the evening we will sing"
Run Code Online (Sandbox Code Playgroud)

我将不胜感激任何帮助.

谢谢

Roy*_*Roy 7

使用爆炸分割变量
(http://php.net/manual/en/function.explode.php)

// Example1
$pizza  = "porcion1 porcion2 porcion3 porcion4 porcion5 porcion6";
$porciones = explode(" ", $pizza);
echo $porciones[0]; // porción1
echo $porciones[1]; // porción2
Run Code Online (Sandbox Code Playgroud)

您可以在此处设置拆分字符 explode("HERE", $var);