foolfell foolfell - 3 months ago 10
PHP Question

how can i refine php sub string and chop functions

I have the php code below, so my question is how can i refine it

$slug = $_SERVER['REQUEST_URI'];
$myslug = substr($slug, 4);
$new_slug = chop($myslug,"?lang=fr");


Thanks in advance for any help

Answer

You could eliminate all those variables.

$slug = chop(substr($_SERVER['REQUEST_URI'], 4),"?lang=fr");