I am trying to walk a foreach
that comes by a path get
.htaccess, but I'm getting the last element and I need to get the full path. For example:
localhost/file/folder1/folder/2/demo.php
Returns only:
demo.php
This is my PHP code:
$part = array_filter(explode('/', route));
$end_part = end($part);
$file = null;
if(isset($part) && $part[0]=="file" && (count($part)>1)){
unset($part[0]);
foreach ($part as $value) {
if($end_part==$value){
$file = $value;
}else{
$file = $value."/";
}
}
echo $file;
}else{
error_response(404);
}