Skip to content

Instantly share code, notes, and snippets.

@richard1122
Created October 5, 2014 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richard1122/85df51f67142a2179239 to your computer and use it in GitHub Desktop.
Save richard1122/85df51f67142a2179239 to your computer and use it in GitHub Desktop.
gets_between
/*
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;
}
@richard1122
Copy link
Author

@zenozeng ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment