Created
October 5, 2014 12:21
-
-
Save richard1122/85df51f67142a2179239 to your computer and use it in GitHub Desktop.
gets_between
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This function split a string into multi part, each part start with(exclude) $start and end with(exclude) $end. | |
$end is optional. | |
Thanks @zenozeng for backend code at QSC mobile. (function get_between) | |
*/ | |
function gets_between($start, $end, $content) { | |
$r = explode($start, $content); | |
$arr = array(); | |
$i = 1; | |
while (isset($r[$i])) { | |
if ($end == NULL) { | |
$arr[] = $r[$i]; | |
} else { | |
$temp = explode($end, $r[$i]); | |
$arr[] = $temp[0]; | |
} | |
++$i; | |
} | |
return $arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@zenozeng ...