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 | |
function strstrbi($haystack, $needle, $before_needle=FALSE, $include_needle=TRUE, $case_sensitive=FALSE) { | |
//Find the position of $needle | |
if($case_sensitive) { | |
$pos=strpos($haystack,$needle); | |
} else { | |
$pos=strpos(strtolower($haystack),strtolower($needle)); | |
} |
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 | |
function Zip($source, $destination) | |
{ | |
if (extension_loaded('zip') === true) | |
{ | |
if (file_exists($source) === true) | |
{ | |
$zip = new ZipArchive(); |
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 | |
function recurse_copy($src,$dst) { | |
$dir = opendir($src); | |
@mkdir($dst); | |
while(false !== ( $file = readdir($dir)) ) { | |
if (( $file != '.' ) && ( $file != '..' )) { | |
if ( is_dir($src . '/' . $file) ) { | |
recurse_copy($src . '/' . $file,$dst . '/' . $file); | |
} |
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 | |
function date_diff_in_days($from, $to = 'now') | |
{ | |
$date1 = strtotime($from); | |
$date2 = strtotime($to); | |
$dateDiff = $date1 - $date2; | |
return floor($dateDiff/(60*60*24)); | |
} |
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
function date_diff_long($from, $to = null) | |
{ | |
$to = (($to === null) ? (time()) : ($to)); | |
$to = ((is_int($to)) ? ($to) : (strtotime($to))); | |
$from = ((is_int($from)) ? ($from) : (strtotime($from))); | |
$units = array | |
( | |
"year" => 29030400, // seconds in a year (12 months) | |
"month" => 2419200, // seconds in a month (4 weeks) |
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 | |
/* | |
Remove non-numeric characters from a string. | |
*/ | |
function stripNonNumeric($str='') { | |
return preg_replace('(\D+)', '', $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 | |
/* | |
* use this function to strip null array entries from an array | |
* useful when doing a db update with pdo/zend_db_table etc.. | |
*/ | |
function strip_null_array_entries($values){ | |
$array = array(); | |
foreach($values as $key=>$value){ |
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 | |
//db update query from form with image upload fields | |
$data = array( | |
'company_name' => $form->getValue('company_name'), | |
'company_image' => $form->getElement('company_image')->getValue(), | |
'company_logo' => $form->getElement('company_logo')->getValue(), | |
'website' => $form->getValue('website') | |
); |
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 | |
class Application_Form_User extends Zend_Form | |
{ | |
public function init() | |
{ | |
/* Form Elements & Other Definitions Here ... */ | |
$this->setName('user'); |
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 | |
function base64_url_encode($input) | |
{ | |
return strtr(base64_encode($input), '+/=', '-_,'); | |
} | |
function base64_url_decode($input) | |
{ | |
return base64_decode(strtr($input, '-_,', '+/=')); |