php dirname() function - how to get directory name from a path in php
dirnameFunction.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>php dirname() function - how to get directory name from a path in php</title>
</head>
<body>
<h2 style="color:Crimson; font-style:italic">php dirname() function example:<br /> how to get directory name from a path</h2>
<hr width="475" align="left" color="Orange" />
<br />
<?php
// this is a file path
$filepath = "c:/test/testcode.php";
//get the directory name
echo "<h1 style=color:Green>";
echo "PATH " . $filepath . "<br />";
echo "DIRECTORY " . dirname($filepath);
echo "</h1>";
?>
</body>
</html>