PHPize Online / SQLize Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function get_absolute_path($path) { $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); $absolutes = array(); foreach ($parts as $part) { if ('.' == $part) continue; if ('..' == $part) { array_pop($absolutes); } else { $absolutes[] = $part; } } return DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $absolutes); } var_dump( real_path('this/is/../a/./test/.///is'), get_absolute_path('this/is/../a/./test/.///is') );
Show:  
Copy Clear