By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

Retrieve current URL aftr

100+
P: 106
I want to retrieve

http://www.mysite.com/directory/page.php

just directory/page.php

How do I do that?
May 9 '10 #1

✓ answered by chimpu

Well , use string explode function and then you will get your result .
See the code below


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. /**
  3. code owner: Rahul Sinha
  4. contact : rahul@zimaudio.com/rahulazm@gmail.com
  5. **/
  6. $str='http://www.mysite.com/directory/page.php';
  7. $arr = explode("com/",$str);
  8. echo $arr[1]; // prints directory/page.php
  9.  
  10. ?>
Regards,
Chimpu

Share this Question
Share on Google+
3 Replies


P: 1
Well , use string explode function and then you will get your result .
See the code below


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. /**
  3. code owner: Rahul Sinha
  4. contact : rahul@zimaudio.com/rahulazm@gmail.com
  5. **/
  6. $str='http://www.mysite.com/directory/page.php';
  7. $arr = explode("com/",$str);
  8. echo $arr[1]; // prints directory/page.php
  9.  
  10. ?>
Regards,
Chimpu
May 10 '10 #2

100+
P: 106
very thanks!
Jun 18 '10 #3

100+
P: 106
I have a related follow up question

http://bytes.com/topic/php/answers/891626-php-explode
Jul 16 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.