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 slug ($string, $delimiter = '-') { | |
$string = trim($string); | |
$string = preg_replace('#[^a-z0-9 ]#i', '', $string); | |
$string = preg_replace('#\s+#', $delimiter, $string); | |
return $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 | |
function human_fsize ($size, $unit = '') | |
{ | |
if (( ! $unit && $size >= 1 << 40) || $unit == 'TB') { | |
return number_format($size / (1 << 40), 2) . ' TB'; | |
} | |
if (( ! $unit && $size >= 1 << 30) || $unit == 'GB') { | |
return number_format($size / (1 << 30), 2) . ' GB'; |
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 | |
/** | |
* Examples of input (assumes $homepage = 'http://site.com'): | |
* | |
* Input: url('') | |
* Return: http://site.com/ | |
* | |
* Input: url('home') | |
* Return: http://site.com/home |
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 | |
/** | |
* Pagination helper written for laravel, available for any project. | |
* | |
* A couple examples: | |
* | |
* [1] $current_page = 1; $total_pages = 1; | |
* <no output, no pagination needed> | |
* |
NewerOlder