在PHP中使用特殊字符剪切字符串

Chr*_*ris 2 php string

我正在搜索一个函数来剪切以下字符串并获取所有内容BEFORE和AFTER

I need this part<!-- more -->and also this part
Run Code Online (Sandbox Code Playgroud)

结果应该是

$result[0] = "I need this part"
$result[1] = "and also this part"
Run Code Online (Sandbox Code Playgroud)

感谢任何帮助!

Fre*_*oux 8

使用explode()PHP中的函数如下:

$string = "I need this part<!-- more -->and the other part.
$result = explode('<!-- more -->`, $string) // 1st = needle -> 2nd = string
Run Code Online (Sandbox Code Playgroud)

然后你打电话给你的结果:

echo $result[0]; // Echoes: I need that part
echo $result[1]; // Echoes: and the other part.
Run Code Online (Sandbox Code Playgroud)