-
Notifications
You must be signed in to change notification settings - Fork 0
/
Strings.php
73 lines (67 loc) · 1.41 KB
/
Strings.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Strings normalization functions
*
* @category helper functions
* @package Normie
* @author David J Eddy <[email protected]>
* @license MIT
* @link https://github.com/davidjeddy/normie
*/
/**
* Swapping $delimiter and $string positions
*
* @param string $string
* @param string $delimiter
* @param int $limit
* @return array<int, string>|false
*/
function norm_explode(string $string, string $delimiter, $limit = PHP_INT_MAX)
{
return explode($delimiter, $string, $limit);
}
/**
* Swapping $glue and $pieces positions
*
* @param array $pieces
* @param string $glue
* @return string
*/
function norm_implode(array $pieces, string $glue): string
{
return implode($glue, $pieces);
}
/**
* Swapping $glue and $pieces positions
*
* @param string $glue
* @param array $pieces
* @return string
*/
function norm_join(array $pieces, string $glue): string
{
return implode($glue, $pieces);
}
/**
* @param mixed $subject
* @param mixed $search
* @param mixed $replace
* @param integer $count
* @return mixed
*/
function norm_str_replace($subject, $search, $replace, $count = 1)
{
return str_replace($search, $replace, $subject, $count);
}
/**
* Added return value.
*
* @param string $string
* @param array $result
* @return array
*/
function norm_parse_str(string $string, array &$result): array
{
parse_str($string, $result);
return $result;
}