substr - Substract a part of a string considering some delimiters in php -


i have variable in php witch can have shape:

$a = 'help&type=client'; $b = 'account#client'; $c = 'info&type=client#new'; 

i need create substract function work this:

echo myfunction($a); //&type=client echo myfunction($b); //#client echo myfunction($c); //&type=client#new 

i rate more simplified answere.

i think simplest way using strpbrk.

$a = 'help&type=client'; $b = 'account#client'; $c = 'info&type=client#new'; echo strpbrk($a, '&#') . php_eol; //&type=client echo strpbrk($b, '&#') . php_eol; //#client echo strpbrk($c, '&#') . php_eol; //&type=client#new 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -