Robert Granlund
asked on
PHP Explode
I'm a little confused:
I'm trying to extract one part of a url, but am not succeeding.
Right now $slug is echoing "member-nameprofile"
I need it to only echo "member-name"
Thanks in advance.
I'm trying to extract one part of a url, but am not succeeding.
URL: http://www.MYSITE.com/members/member-name/profile/
$str = $_SERVER["REQUEST_URI"];
$array = explode("/", $str, 3);
$slug_a = $array[2];
$slug = str_replace('/', '', $slug_a);
echo $slug;
Right now $slug is echoing "member-nameprofile"
I need it to only echo "member-name"
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
edit.
Actually limiting it makes no sense in this case! Ray's way is the best way.