Posted By

timberjorge on 09/12/10


Tagged

php parameter uri segment


Versions (?)

URI Segment


 / Published in: PHP
 

  1. <?php
  2.  
  3. function segment($index) {
  4. $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
  5.  
  6. $path = (strpos($path, '/') == 0) ? ltrim($path, '/') : $path ;
  7.  
  8. $path_chunked = explode('/', $path);
  9.  
  10. return ($index > count($path_chunked) ) ? FALSE : $path_chunked[$index-1];
  11. }
  12.  
  13. ?>

Report this snippet  

You need to login to post a comment.