我想知道如何将以下字符串拆分为数组:
带两个臂式卷发器,腿部卷发器和杠铃架的训练台,Max。载荷:160kg
输出应为:
array (
[0] => 'Training bench with two arm curlers, leg curler and barbell rack',
[1] => 'Max. load: 160kg'
);
规则可以是“,{CAPITAL LETTER} ”(逗号+空格+大写字母)。 在这种情况下,“ ,M '
你可以告诉我吗?谢谢。
答案 0 :(得分:3)
这可按要求运作
$str = "Training bench with two arm curlers, leg curler and barbell rack, Max. load: 160kg";
print_r(preg_split('/\,\ (?=[A-Z])/m',$str));
输出:
Array
(
[0] => Training bench with two arm curlers, leg curler and barbell rack
[1] => Max. load: 160kg
)