Jump to content

How to get part of your URL?


Sako

Recommended Posts

Hi,

 

I am new to Php. Let's say that my URLs look like:

 

http://www.mywebsite.com/category/COMPUTERS/apple.php

http://www.mywebsite.com/category/COMPUTERS/ibm.php

http://www.mywebsite.com/category/COMPUTERS/dell.php

 

I would like to have a variable defined as 'apple', 'ibm', 'dell'.

 

The code I have below does not work well because these can have different number of characters... any help?

 

$self = substr($_SERVER['PHP_SELF'], -8,4);

echo $self;

 

Thanks a lot!

 

Link to comment
https://forums.phpfreaks.com/topic/208115-how-to-get-part-of-your-url/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.