PHP Extract only the Filename from UNC Path
<p>I am a <strong>complete</strong> novice to PHP and would like some advise on the following;
I'm trying to create an Intranet page that looks up all pdf documents in a UNC path and the returns them in a list as hyperlinks that opens in a new window. I'm nearly there however the following code displays the FULL UNC path - My question how can I display only the Filename (preferably without the .pdf extension too). I've experimented with the <em>basename</em> function but can't seem to get the right result.</p>

<pre><code>//path to Network Share
$uncpath = "//myserver/adirectory/personnel/";
//get all files with a .pdf extension.
$files = glob($uncpath . "*.pdf");
//print each file name
foreach ($files as $file) 
{
echo "&lt;a target=_blank href='File:///$file'&gt;$file&lt;/a&gt;&lt;br&gt;"; 
}
</code></pre>

<p>The links work fine it just the display text shows //myserver/adirectory/personnel/document.pdf rather than just 'document'. Note the above code was taken from another example I found whilst researching. If there's a whole new better way then I'm open to suggestions.</p>
