So I have a URI that is returned like so /intelliship/ I need the beginning slash and trailing slash to be removed from that URI.
Attempted (FAILED) code:
<?php
$value = $_SERVER['REQUEST_URI'];
function __construct($value){
if(strpos($value,'/')==FALSE){
return trim(substr(strrchr($value, ' '), 1 ));
}else{
return trim(substr($value, strpos($value,'/')),'/');
}
$value = ucwords($value);
}
?>
This doesn’t strip any slashes and is pretty sloppy code. Any help would be greatly appreciated.
Why not just:
There is no need for regex or checking what is the first or last character.