| | |
| | | foreach ($var as $key => $value) |
| | | { |
| | | // enclose key with quotes if it is not variable-name conform |
| | | if (!ereg("^[_a-zA-Z]{1}[_a-zA-Z0-9]*$", $key) || is_js_reserved_word($key)) |
| | | if (!preg_match('/^[_a-zA-Z]{1}[_a-zA-Z0-9]*$/', $key) || is_js_reserved_word($key)) |
| | | $key = "'$key'"; |
| | | |
| | | $pairs[] = sprintf("%s%s", $is_assoc ? "$key:" : '', json_serialize($value)); |
| | |
| | | * Parse a human readable string for a number of bytes |
| | | * |
| | | * @param string Input string |
| | | * @return int Number of bytes |
| | | * @return float Number of bytes |
| | | */ |
| | | function parse_bytes($str) |
| | | { |
| | | if (is_numeric($str)) |
| | | return intval($str); |
| | | return floatval($str); |
| | | |
| | | if (preg_match('/([0-9]+)([a-z])/i', $str, $regs)) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | return intval($bytes); |
| | | return floatval($bytes); |
| | | } |
| | | |
| | | /** |