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 numeric value using encapsulated NumberFormatter functions | |
* | |
* @param float $amount | |
* @param array $kwargs | |
* @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 | |
* @return string|false |
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 $kwargs | |
* @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 | |
* @return string|false |
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 $kwargs | |
* @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 | |
* @return string|false |
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 | |
/** | |
* Filter out non-allowed parameters in the request input and protect parameter values against XSS | |
* | |
* @param int $type INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, INPUT_ENV | |
* @param array $allowed_params | |
* @link https://www.php.net/manual/en/function.filter-input-array.php | |
* @return array | |
*/ | |
function sanitize_input_array($type, array $allowed_params) { |
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 array_map_recursive($callback, $array) { | |
$func = function ($item) use (&$func, &$callback) { | |
return is_array($item) ? array_map($func, $item) : call_user_func($callback, $item); | |
}; | |
return array_map($func, $array); | |
} |
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 mb_str_split($string, $length = 1, $encoding = NULL) { | |
if (!is_null($string) && !is_scalar($string)) { | |
$type = gettype($string) === 'object' ? get_class($string) : gettype($string); | |
throw new \Exception(sprintf('mb_str_split(): Argument #1 ($string) must be of type string, %s given', $type)); | |
} | |
if ((!is_null($length) && !is_numeric($length)) || $length === '') { | |
$type = gettype($length) === 'object' ? get_class($length) : gettype($length); | |
throw new \Exception(sprintf('mb_str_split(): Argument #2 ($string) must be of type int, %s given', $type)); | |
} |
NewerOlder