Update string.utils.php
This commit is contained in:
parent
4deace135a
commit
6295c19cbd
|
@ -116,26 +116,21 @@ if(!check_function_exists("multi_explode")) {
|
||||||
|
|
||||||
if(!check_function_exists("multi_strpos")) {
|
if(!check_function_exists("multi_strpos")) {
|
||||||
function multi_strpos($string, $delimiters, $offset=0) {
|
function multi_strpos($string, $delimiters, $offset=0) {
|
||||||
$pos = false;
|
$pos = strlen(string) - 1;
|
||||||
|
$d = array();
|
||||||
|
|
||||||
if($offset > 0) {
|
if($offset > 0) {
|
||||||
$string = substr($offset);
|
$string = substr($offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($delimiters as $s) {
|
foreach($delimiters as $s) {
|
||||||
$cur_pos = strpos($string, $s);
|
$new_pos = strpos($string, $s);
|
||||||
if($cur_pos !== false) {
|
if($new_pos !== false && $pos > $new_pos) {
|
||||||
if($pos !== false) {
|
$pos = $new_pos;
|
||||||
if($pos > $cur_pos) {
|
|
||||||
$pos = $cur_pos;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$pos = $cur_pos;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pos;
|
return ($pos < 0) ? false : $pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +141,7 @@ if(!check_function_exists("multi_str_split")) {
|
||||||
if(is_string($string)) {
|
if(is_string($string)) {
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$pos = -1;
|
$pos = -1;
|
||||||
while($pos !== false) {
|
while(!($pos !== false)) {
|
||||||
$offset = $pos + 1;
|
$offset = $pos + 1;
|
||||||
$pos = multi_strpos($string, $delimiters, $offset);
|
$pos = multi_strpos($string, $delimiters, $offset);
|
||||||
$strings[] = substr($string, $offset, $pos - $offset);
|
$strings[] = substr($string, $offset, $pos - $offset);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user