Written by:David Aldridge
4/19/2011 1:21 PM 

Normally you would use explode and simply assign it to an array and reference the element you want.  But that takes more than one line.  Making it bad for lazy programmers who want to do it all at the last minute in one line.

This is what PHP will not allow you to do on one line:

echo explode(" ","2011-01-01 00:00:00")[1];

If you have PHP 5.3 or later installed then you can do this:

echo stristr("2011-01-01 00:00:00"," ",true);

However if you don't then you have to do this to make it work on one line:

echo substr("2011-01-01 00:00:00",0,stripos("2011-01-01 00:00:00"," "));



Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
You must be logged in and have permission to create or edit a blog.