Use PHP Substr() and Strpos() to Split a String

by damonp on January 30, 2007

in PHP,Snippets

To split a variable $act like:

$act = 'coupon:edit';
$act = 'coupon:delete';
$method = substr($act, strpos($act, ':')+1);

Popularity: 9%

Most Popular Posts

Damon Parker is a freelance sysadmin and web developer in Texas. He specializes in server setup, server security and high performance server configurations. Need help setting up a web server or getting a server back online after a crash or hack? Email Damon

{ 3 comments… read them below or add one }

divi August 11, 2010 at 8:58 am

good

Reply

Shashi kanth December 9, 2011 at 6:57 am

Thanks for the example…

Reply

hehe January 19, 2012 at 2:58 am

yeah, good

Reply

Leave a Comment

Previous post:

Next post: