Return to Snippet

Revision: 42693
at March 9, 2011 05:11 by anagaiyahoocom


Initial Code
$cur_path = JURI::current();
$slash_pos = strrpos($cur_path,'/')+1;
$dot_pos = strpos($cur_path,'.html');
$page_len = $dot_pos!==false ? $dot_pos-$slash_pos : 0;
if($page_len>0)
  $cur_page = substr($cur_path,$slash_pos,$page_len);	
else
  $cur_page = substr($cur_path,$slash_pos);

echo $cur_page;

e.g.

http://www.domain.com/somepage.html

output:

somepage

Initial URL

                                

Initial Description
This will extract page handle between last slash and .html

Initial Title
Extracting Page Handle From URL

Initial Tags
php

Initial Language
PHP