View [PHP] Get Domain From Email Address (multiple @ symbol support)
// too many php developers use the example on the php `strstr` page:
// http://php.net/manual/en/function.strstr.php
// Yet, amazingly, the following is a valid email address:
// foo@bar@domain.tld
// If you use the example on the strstr page you end up with:
// @bar@domain.tld -- which is of course not what you want.
// So what is a fast and extremely low memory method to return
// just the domain.tld when? The following seems to be the best.
$email = 'foo@bar@domain.tld';
View Power of (U)GUID Lengths
If you use your own (U)(G)UID generator for unique identifiers, say UserGUID or WidgetGUID or whatnot, there is very little chance you are ever going to need to use something like `md5(time())` or `bin2hex(random_bytes(5))` or whatever.
Using just a very basic (and all lowercase) `a-z` & `0-9` combination will result in a 36 character string.
abcdefghijklmnopqrstuvwxyz0123456789 = 36 characters
If we take those 36 characters to the `power of` we get the follow possible unique vales:
[1] = 36
[2] = 1,296
View htaccess domain.tld{dash}usersname
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(register|contact|signin|policies) [NC]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ /profile.php?id=$1 [L,QSA]
View [PHP] Are All Characters Identical?
$word = 'dddddd';
if (empty(str_replace(mb_substr(trim($word),-1),'',trim($word)))) {
die('all the characters are identical');
}
View [PHP] Jewish Date (in english)
$Today = gregoriantojd(date('n'),date('j'),date('Y'));
$Month = jdmonthname($Today,4);
$Date = jdtojewish($Today);
list($notused, $Day, $Year) = explode('/',$Date);
echo "$Month $Day, $Year";
View [PHP] Loop Dates Backwards
$start = new DateTime('now');
$end = new DateTime('- 7 day');
$diff = $end->diff($start);
$interval = DateInterval::createFromDateString('-1 day');
$period = new DatePeriod($start, $interval, $diff->days);
foreach ($period as $date) {
echo $date->format('m-d') . '<br>'; // or whatever you want to do
}
View [PHP] intToOrdinal()
//
//
///////////////////////////////////////////////////////////////////////
// intToOrdinal()
//
// - Description:
// Add Ordinal Text To Integer
//
// - Usage:
// $str_return = intToOrdinal($number);
View [PHP] bitly_MakeShortLink()
View [PHP] howManyDaysBetweenTwoDays()
//
//
///////////////////////////////////////////////////////////////////////
// howManyDaysBetweenTwoDays()
//
// - Description:
// How many days between two unix time stamps
// 86400 is derived from:
// 60 (seconds) multiplied by 60 (minutes) multiplied by 24 (hours)
//