-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMultiExplode.php
38 lines (38 loc) · 1017 Bytes
/
MultiExplode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
*
* @Name : PHPMultiExplode/MultiExplode.php
* @Version : 1.0
* @Programmer : Max
* @Date : 2019-04-15
* @Released under : https://github.com/BaseMax/PHPMultiExplode/blob/master/LICENSE
* @Repository : https://github.com/BaseMax/PHPMultiExplode
*
**/
function mexplode($delimiters=null, $input="") {
if($delimiters === null || count($delimiters) == 0) {
$delimiters=array(" ");
}
$input = str_replace($delimiters, $delimiters[0], $input);
return explode($delimiters[0], $input);
// $items = explode($delimiters[0], $ready);
// return $items;
}
function mexplodes($delimiters=null, $input="") {
if($delimiters === null || count($delimiters) == 0) {
$delimiters=array(" ");
}
$query="";
foreach($delimiters as $delimiter) {
$query.=preg_quote($delimiter)."|";
}
$query=rtrim($query, "|");
if($query != "") {
$query="(".$query.")";
print $query."\n";
return preg_split("/(".$query.")/", $input);
// $output = preg_split("/(@|vs)/", $input);
// return $output;
}
return $input;
}