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
/** | |
* p | |
* Better print_r() for debugging purposes. | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function p($data){ | |
$debug = debug_backtrace(); |
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
/** | |
* array_flatten | |
* Flattens any array. | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function array_flatten($array){ | |
$return = array(); | |
array_walk_recursive($array, function($a) use (&$return) { $return[] = $a; }); |
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
/** | |
* in_arrayi | |
* Case insensitive in_array(). | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function in_arrayi($needle, $haystack){ | |
return in_array(strtolower($needle), array_map('strtolower', $haystack)); | |
} |
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
/** | |
* in_arrayr | |
* Multi dimensional in_array(). | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function in_arrayr($needle, $haystack, $strict = false) { | |
foreach($haystack as $item){ | |
if(($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_arrayr($needle, $item, $strict))){ |
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
/** | |
* array_searchr | |
* Multi dimensional array_search(). | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function array_searchr($id, $array, $key, $return = false, $query = false){ | |
$matches = array(); |
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
/** | |
* array_contains | |
* Check if string contains word from array. | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function array_contains($str, array $arr){ | |
foreach($arr as $a){ | |
if(stripos($str, $a) !== false) return true; |
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
/** | |
* word_limit | |
* Cuts a string by word count. | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function word_limit($string, $limit, $end = '…'){ | |
$words = explode(" ", $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
/** | |
* extract_youtube_video | |
* Extracts a YouTube iframe video from a string. | |
* | |
* @since 1.0.0 | |
* @version 1.0.0 | |
**/ | |
function extract_youtube_video($string, $decode = true){ | |
// Decode string. | |
$content = ($decode) ? html_entity_decode($string, ENT_QUOTES, 'utf-8') : $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
# Dev images from live domain. | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule (.*\.(gif|jpg|png)) http://livedomain.com/$1 [QSA,R,L] | |
</IfModule> |
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
#!/bin/bash | |
# | |
# musicsorter.sh | |
# | |
# About: | |
# Will sort a directory of music files by recognising the track name and sorting them into directories like Artist > Track Name.ext. | |
# | |
# How To Use: | |
# `bash musicsorter.sh ./path/to/directory` | |
# |
OlderNewer