简体   繁体   中英

Split php string and keep delimiter with the first output

I'm trying to split a php string in to parts the first one include the delimiter but the second one doesn't

$string = "abc==123";

What I want exactly is to get

$string['0'] = "abc==";
$string['1'] = "123";

Thanks for help

Simple enough

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

I believe you want the function strstr

http://us1.php.net/strstr

You can use PHP's explode function,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM