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 uuid() { | |
$data = random_bytes(16); | |
$data[6] = chr((ord($data[6]) | 0xC0) & 0x4F); | |
$data[8] = chr((ord($data[8]) | 0xC0) & 0xBF); | |
$str = bin2hex($str); | |
return sprintf('%s-%s-%s-%s-%s', substr($str, 0, 8), substr($str, 8, 4), substr($str, 12, 4), substr($str, 16, 4), substr($str, 20)); | |
} |
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 | |
/** | |
* This class is intended as a tool to aid creating loops with special events in | |
* them. You can instance the class before running your loop and simply trigger | |
* the next() method whenever you need it. | |
* | |
* E.g. This is specially useful if you need to print a certain HTML tag every | |
* X executions of your loop. You can do it like this: | |
* |
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 array_filter_recursive($element) { | |
if ( is_array($element) ) { | |
foreach ($element as &$subelement) { | |
$subelement = self::array_filter_recursive($subelement); | |
} | |
return array_filter($element); | |
} | |
return !!$element; | |
} |