假设要拆分的$text是:
Question 1 - Parabolas
... /**/
Question 2 - Permutations
... /**/
Question 3 - Integration
一个人如何分裂才能得到一个神器?
“问题X -”X可以代表任何数字。通过:
$question = explode("Question X -", $text);
我绝对必须包括后面的短跑。
发布于 2017-06-22 13:38:29
你得用regex来做这个。
示例:
$text = "Question 1 - Parabolas";
preg_match('/Question [0-9]+ - (.*)/', $text, $matches);
echo $matches[1];
输出:
Parabolas
如果你想用多行来做这件事,你必须preg_match_all
,然后循环通过匹配。问题将在索引1!
https://stackoverflow.com/questions/44700946
复制相似问题