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
| <?php | |
| function encode_query(string $url): string { | |
| if ($query = parse_url($url, PHP_URL_QUERY)) { | |
| [$path] = explode($query, $url, 2); | |
| parse_str($query, $data); | |
| $query = http_build_query($data, "", NULL, PHP_QUERY_RFC3986); | |
| if ($fragment = parse_url($url, PHP_URL_FRAGMENT)) { | |
| $fragment = '#'.rawurlencode($fragment); | |
| } | |
| return join([$path, $query, $fragment]); |
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
| <?php | |
| function filter_sanitize_string($value, $flags = 0) { | |
| if ($flags & FILTER_FLAG_EMPTY_STRING_NULL && $value === "") { | |
| return null; | |
| } | |
| if (!(is_scalar($value) || is_null($value))) { | |
| return false; | |
| } | |
| // Strip HTML tags and remove NUL bytes |
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
| <?php | |
| if (!function_exists('array_column')) { | |
| function array_column(array $array, $column_key, $index_key = NULL) { | |
| $output = array(); | |
| foreach ($array as $row) { | |
| if (is_null($index_key)) { | |
| $output []= is_null($column_key) ? $row : $row[$column_key]; | |
| } | |
| else { | |
| $output[$row[$index_key]] = is_null($column_key) ? $row : $row[$column_key]; |
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
| function encodeQueryString(params, isPostRequest) { | |
| var query = new Array(); | |
| for (var key in params) { | |
| if (params.hasOwnProperty(key)) { | |
| var value = params[key]; | |
| if (Object.prototype.toString.call(value) === "[object Array]") { | |
| for (var i = 0, n = value.length; i < n; i++) { | |
| query.push(encodeURIComponent(key + "[]") + "=" + encodeURIComponent(value[i])); | |
| } | |
| } else { |
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
| function http_query(data, arg_separator) { | |
| var query = []; | |
| for (var key in data) { | |
| query.push(encodeURIComponent(key) + "=" + encodeURIComponent(data[key].toString())); | |
| } | |
| return array.join(arg_separator || "&"); | |
| } |
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
| function http_build_query(data, numeric_prefix, arg_separator, encoding_type_RFC1738) { | |
| var i = 0, j = 0, encoded_key, encoded_val, query = []; | |
| if (typeof arg_separator === "undefined") { | |
| arg_separator = "&"; | |
| } | |
| for (var key in data) { | |
| if (data.hasOwnProperty(key)) { | |
| var value = data[key]; | |
| if (Object.prototype.toString.call(value) === "[object Array]") { | |
| for (var i = 0; i < value.length; i++) { |
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
| <?php | |
| function br2nl($string) { | |
| return preg_replace('/<br(\s*)?\/?>/i', PHP_EOL, $string); | |
| } |
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
| <?php | |
| /** | |
| * Localize number value using encapsulated NumberFormatter functions | |
| * | |
| * @param float $amount | |
| * @param array $args | |
| * @link https://www.php.net/manual/en/numberformatter.format.php | |
| * @link https://www.php.net/manual/en/numberformatter.create.php | |
| * @link https://www.php.net/manual/en/class.locale.php | |
| * @link https://unicode.org/reports/tr35/tr35-numbers.html#table-number-pattern-character-definitions |
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
| <?php | |
| /** | |
| * Localize currency using encapsulated NumberFormatter functions | |
| * | |
| * @param float $amount | |
| * @param array $args | |
| * @link https://www.php.net/manual/en/numberformatter.formatcurrency.php | |
| * @link https://www.php.net/manual/en/numberformatter.create.php | |
| * @link https://www.php.net/manual/en/class.locale.php | |
| * @link https://unicode.org/reports/tr35/tr35-numbers.html#table-number-pattern-character-definitions |
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
| <?php | |
| /** | |
| * Localize datetime using encapsulated IntlDateFormatter functions | |
| * | |
| * @param IntlCalendar|DateTimeInterface|array|string|int|float $datetime | |
| * @param array $args | |
| * @link https://www.php.net/manual/en/intldateformatter.format.php | |
| * @link https://www.php.net/manual/en/intldateformatter.create.php | |
| * @link https://www.php.net/manual/en/class.locale.php | |
| * @link https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table |
NewerOlder