Membership Membership:
Latest New User Latest: vpros
Past 24 Hours Past 24 Hours: 0
Prev. 24 Hours Prev. 24 Hours: 0
User Count Overall: 137

People Online People Online:
Visitors Visitors: 9
Members Members: 0
Total Total: 9

NakedMCSE Computer Tech Support Forums

So you have passed all of the exams and you are now out in the real world of windows servers, linux servers and freebsd servers faced with a tech support problem you have never seen before...

Find free online tech support in the forums below, respecting that advice is free, but work beyond advice is not...

The General forum is provided for off topic discussion.

You need a user account to post - please Register or Login.

Online Tech Support Forums
 
  Forum  Discussions  General  Using explode() on a single line in PHP
Previous Previous
 
Next Next
New Post 4/19/2011 4:17 PM
Informative
  Walker
119 posts
www.lairdscomputer.com
10th Level Poster


Using explode() on a single line in PHP 

Ok so the title is a little misleading - 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.

PHP does not allow you to do this 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"," "));

Walker
www.lairdscomputer.com
 

 
Previous Previous
 
Next Next
  Forum  Discussions  General  Using explode() on a single line in PHP
Send me One Million FREE Guaranteed Visitors