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
| /* creates a compressed zip file */ | |
| // @link http://webdeveloperplus.com/php/21-really-useful-handy-php-code-snippets/ | |
| function create_zip($files = array(),$destination = '',$overwrite = false) { | |
| //if the zip file already exists and overwrite is false, return false | |
| if(file_exists($destination) && !$overwrite) { return false; } | |
| //vars | |
| $valid_files = array(); | |
| //if files were passed in... | |
| if(is_array($files)) { | |
| //cycle through each file |
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
| /***** | |
| *@dir - Directory to destroy | |
| *@virtual[optional]- whether a virtual directory | |
| *@link http://webdeveloperplus.com/php/21-really-useful-handy-php-code-snippets/ | |
| */ | |
| function destroyDir($dir, $virtual = false) | |
| { | |
| $ds = DIRECTORY_SEPARATOR; | |
| $dir = $virtual ? realpath($dir) : $dir; | |
| $dir = substr($dir, -1) == $ds ? substr($dir, 0, -1) : $dir; |
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
| /** | |
| * Create a "normal" array from a multidimensional one | |
| * | |
| * @param array $array multidimensional array to convert | |
| * @return array | |
| * @link http://stackoverflow.com/questions/6785355/convert-multidimensional-array-into-single-array/6785366#6785366 | |
| * | |
| */ | |
| public function array_flatten(array $array) { | |
| if (!is_array($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
| /** | |
| * | |
| * empty() function for multiple values | |
| * | |
| * @link http://stackoverflow.com/questions/4993104/using-ifempty-with-multiple-variables-not-in-an-array | |
| * @return bool | |
| * | |
| */ | |
| public function mempty() { | |
| foreach (func_get_args() as $arg) |
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_search for multidimensional arrays | |
| * | |
| * @param string $needle | |
| * @param array $haystack | |
| * @return int|bool | |
| * | |
| */ | |
| public function recursive_array_search($needle, array $haystack) { | |
| foreach ($haystack as $key => $value) { |
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 | |
| /** | |
| * Case in-sensitive array_search() with partial matches | |
| * | |
| * @param string $needle The string to search for. | |
| * @param array $haystack The array to search in. | |
| * | |
| * @author Bran van der Meer <[email protected]> | |
| * @since 29-01-2010 | |
| */ |
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
| /** | |
| * Checks if an incoming request is an ajax | |
| * | |
| * @return bool | |
| */ | |
| public function IsXHttpRequest() { | |
| if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { | |
| return true; | |
| } else { | |
| return false; |