String中的Split / Explode仅标识第一个元素(符号或Word)?

时间:2014-12-08 04:18:42

标签: php string split explode

我有下一个字符串:

String = "Name: James, Training, Physician, Hobbies: Sports, Reading, Age: 24".

使用以下字符串与第一个'分享:'发现,做出以下结论:

stringsplit1 = "Name";
stringsplit2 = "James, Training, Physician, Hobbies: Sports, Reading, Age: 24";

或在数组中。 :S

1 个答案:

答案 0 :(得分:1)

explode()

explode(':',$string,2);
                    ^ ------------> limit [int]

完整代码:

$string = "Name: James, Training, Physician, Hobbies: Sports, Reading, Age: 24";
$ar = explode(":",$string,2);
print_r($ar);