Our Picks
Top content from across the community, hand-picked by us.
What's your internet speed?
Nathan posted a topic in General Chat,
So what speed do you guys get?
I'm at 30 down and 5 up on Cable.
I'm at 30 down and 5 up on Cable.
-
- 54 replies
PHP strtok
Prodjex posted a topic in PHP,
The PHP function strtok splits a string one by one.
In the example below I’m trying to split off everything after the ? in the URL.
https://www.facebook.com/LiquidWebInc?fref=ts
https://www.facebook.com/CocaColaUnitedStates?brand_redir=1
In PHP I was able to do this with the following:
$facebookURL = 'https://www.facebook.com/LiquidWebInc?fref=ts';
$cocacolaURL = 'https://www.facebook.com/CocaColaUnitedStates?brand_redir=1';
$facebookURL = strtok($facebookURL, '?');
$cocacolaURL = strtok($cocacolaURL, '?');
Check out the demo here.
The post PHP strtok appeared first on Kansas City Web Consulting | Kansas City Web Development.
View the full article
In the example below I’m trying to split off everything after the ? in the URL.
https://www.facebook.com/LiquidWebInc?fref=ts
https://www.facebook.com/CocaColaUnitedStates?brand_redir=1
In PHP I was able to do this with the following:
$facebookURL = 'https://www.facebook.com/LiquidWebInc?fref=ts';
$cocacolaURL = 'https://www.facebook.com/CocaColaUnitedStates?brand_redir=1';
$facebookURL = strtok($facebookURL, '?');
$cocacolaURL = strtok($cocacolaURL, '?');
Check out the demo here.
The post PHP strtok appeared first on Kansas City Web Consulting | Kansas City Web Development.
View the full article
-
- 0 replies
PHP DateTime Class and Functions
Prodjex posted a topic in PHP,
With PHP 5 they introduced the DateTime class. Prior to that everyone used strtotime, date, etc…commands to achieve the same results. I was a late adopter and continued to use the old commands. Recently I decided it’s been long enough and it’s time to take a look at this new class and apply it.
This example is a simple how to on showing the difference between two dates in day format.
So my start date here is 2016-05-04 10:20:42 as it’s stored in the MySQL timestamp field of my database. The end date is another date in the same format of YYYY-MM-DD HH:MM:SS.
My first attempt mixed some of the old and new functions together to get my result.
$reg_temp = strtotime('2016-05-04 10:20:42');
$registration_date = date("Y-m-d", $reg_temp);
$exp_temp = strtotime('2017-05-04 10:20:42');
$expiration_date = date("Y-m-d", $exp_temp);
$registration_date = date_create($registration_date);
$expiration_date = date_create($expiration_date);
$diff=date_diff($registration_date,$expiration_date);
echo $diff->format("%R%a days");
While it did get me the end result, that’s a lot of code to accomplish what I want. And I also want to force myself to only use the new DateTime class. After a few more iterations I came up with this that does the same job in 4 nice and clean lines of code:
$registration_date = date_create('2016-05-04 10:20:42'); //Replace static date with your database field
$expiration_date = date_create('2017-05-04 10:20:42'); //Replace static date with your database field
$diff=date_diff($registration_date,$expiration_date);
echo $diff->format("%R%a days");
Much better. You can see the demo output here.
The post PHP DateTime Class and Functions appeared first on Kansas City Web Consulting | Kansas City Web Development.
View the full article
This example is a simple how to on showing the difference between two dates in day format.
So my start date here is 2016-05-04 10:20:42 as it’s stored in the MySQL timestamp field of my database. The end date is another date in the same format of YYYY-MM-DD HH:MM:SS.
My first attempt mixed some of the old and new functions together to get my result.
$reg_temp = strtotime('2016-05-04 10:20:42');
$registration_date = date("Y-m-d", $reg_temp);
$exp_temp = strtotime('2017-05-04 10:20:42');
$expiration_date = date("Y-m-d", $exp_temp);
$registration_date = date_create($registration_date);
$expiration_date = date_create($expiration_date);
$diff=date_diff($registration_date,$expiration_date);
echo $diff->format("%R%a days");
While it did get me the end result, that’s a lot of code to accomplish what I want. And I also want to force myself to only use the new DateTime class. After a few more iterations I came up with this that does the same job in 4 nice and clean lines of code:
$registration_date = date_create('2016-05-04 10:20:42'); //Replace static date with your database field
$expiration_date = date_create('2017-05-04 10:20:42'); //Replace static date with your database field
$diff=date_diff($registration_date,$expiration_date);
echo $diff->format("%R%a days");
Much better. You can see the demo output here.
The post PHP DateTime Class and Functions appeared first on Kansas City Web Consulting | Kansas City Web Development.
View the full article
-
- 0 replies
Star Tours 30 Year Anniversary
Nathan posted a topic in General Chat,
January 9th was the 30th anniversary of the ride Star Tours at Disney. Crazy it's been that long, couldn't count how many times I've been on it.
I was reading some on it earlier and also saw this, can't believe that cost, 32 million, especially back in the 1980's, insane!
Also didn't realize it had been retired and replaced by a newer version. Anyone else remember waiting in line and all the cool stuff to look at?
I was reading some on it earlier and also saw this, can't believe that cost, 32 million, especially back in the 1980's, insane!
Also didn't realize it had been retired and replaced by a newer version. Anyone else remember waiting in line and all the cool stuff to look at?
-
- 1 reply