This file contains 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 | |
/** | |
* Form acronyms from a string | |
* @param string $str | |
*/ | |
function acronym ($str) | |
{ |
This file contains 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 | |
/** | |
* Replaces spaces between string by hyphens | |
* @param string $str | |
* @return string | |
*/ | |
function create_slug ($str) | |
{ |
This file contains 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 | |
/** | |
* Removes accents from a string | |
* @param int $str | |
* @return string | |
*/ | |
function strip_accents ($str) | |
{ |
This file contains 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 | |
/** | |
* Generate a random password | |
* @param int $length | |
*/ | |
function random_password ($length = 8, $chars = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789") | |
{ |
This file contains 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 | |
/** | |
* Test if URL is valid | |
* @author SpikeZ | |
* @param string $str | |
* @return bool | |
*/ | |
function is_valid_url ($uri) |
This file contains 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 | |
/** | |
* Test if date is equal | |
* @param string $date1 | |
* @param string $date2 (default today timestamp) | |
* @param string $format (default d/m/Y) | |
* @return bool | |
*/ |
This file contains 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 | |
/** | |
* Indent JSON strings | |
* @param string $str | |
* @return string json | |
*/ | |
function indent_json ($str) |
This file contains 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 | |
/** | |
* Converts HEX color code to RGB(A) | |
* @param string $color | |
* @param int $opacity | |
* @return string | |
*/ | |
function hex2rgba ($color, $opacity = false) |
This file contains 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 | |
/** | |
* Format bytes to KB, MB, GB... | |
* @param int $bytes | |
* @param int $precision | |
* @return string | |
*/ | |
function format_bytes ($bytes, $precision = 2) |
This file contains 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 | |
/** | |
* Calculate average of array values | |
* @param array $array | |
* @return int $average | |
*/ | |
function array_average ($arr) | |
{ |
NewerOlder