拆分php字符串并在第一个输出中保留分隔符

拆分php字符串并在第一个输出中保留分隔符,php,split,Php,Split,我试图将一个php字符串拆分为多个部分,第一个部分包含分隔符,但第二个部分不包含分隔符 $string = "abc==123"; 我真正想要的是得到 $string['0'] = "abc=="; $string['1'] = "123"; 谢谢你的帮助很简单 <?php $string = explode("==", $string); $string[0] .= "=="; ?> 足够简单 <?php $string = explode("

我试图将一个php字符串拆分为多个部分,第一个部分包含分隔符,但第二个部分不包含分隔符

$string = "abc==123";
我真正想要的是得到

$string['0'] = "abc==";
$string['1'] = "123";
谢谢你的帮助

很简单

<?php
    $string = explode("==", $string);
    $string[0] .= "==";
?>

足够简单

<?php
    $string = explode("==", $string);
    $string[0] .= "==";
?>

您可以使用PHP的explode函数

$data  = "abc==123";
$result = explode("==", $data);
echo $result[0]. "==";
echo $result[1];

您可以使用PHP的explode函数

$data  = "abc==123";
$result = explode("==", $data);
echo $result[0]. "==";
echo $result[1];

我相信您需要strstr函数


我相信您需要strstr功能


我已经考虑过了。我想用另一种方式做@用户2898514,虽然还有其他的方法,但这很简单而且有效。我想,我只是想用它,然后我已经想过了。我想用另一种方式做@用户2898514,虽然还有其他方法,但这很简单而且有效。我想,我只想使用它。是的,但这不会包括每个结果中第一个结果为thuctanate的“==”字符串。是的,但不会包括每个结果中第一个结果为thuctanate的“==”字符串。哦,是的。。。就是这样:)哦,是的。。。就这样:)