Various useful helper functions.
This file is part of Ratatöskr. Ratatöskr is licensed unter the MIT / X11 License. See “ratatoeskr/licenses/ratatoeskr” for more information.
ratatoeskr/ | Various useful helper functions. |
Functions | |
array_repeat | $val - $n - |
array_blend | Blend multiple arrays together. |
array_filter_empty | Filters all empty elements out of an array. |
array_filter_keys | Like PHPs `array_filter`, but callback will get the key, not the value of the array element. |
array_kvpairs_to_assoc | Convert array of key-value pairs to an associative array. |
intcmp | Compare integers (equavilent to strcmp) |
ucount | Count elements of an array matching unser-defined rules. |
vcount | Counts how often $value appears in $array. |
self_url | Gets current URL. |
htmlesc | Escape HTML (shorter than htmlspecialchars) |
delete_directory | Delete a directory and all of its content. |
Constants | |
SITE_BASE_PATH | The Base path of this ratatoeskr site. |
function ucount( $array, $callback )
Count elements of an array matching unser-defined rules.
$array | The input array. |
$callback | A callback function. It will be called with the current value as the only parameter. The value is counted, if callback returns TRUE. |
Number of elements where $callback returned TRUE.
$val - $n -
function array_repeat( $val, $n )
Blend multiple arrays together.
function array_blend()
Filters all empty elements out of an array.
function array_filter_empty( $input )
Like PHPs `array_filter`, but callback will get the key, not the value of the array element.
function array_filter_keys( $input, $callback )
Convert array of key-value pairs to an associative array.
function array_kvpairs_to_assoc( $input )
Compare integers (equavilent to strcmp)
function intcmp( $a, $b )
Count elements of an array matching unser-defined rules.
function ucount( $array, $callback )
Counts how often $value appears in $array.
function vcount( $array, $value )
Gets current URL.
function self_url()
Escape HTML (shorter than htmlspecialchars)
function htmlesc( $text )
Delete a directory and all of its content.
function delete_directory( $dir )