Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Captura um nome de arquivo de devolve um array de 2 elementos com o nome e extensão.
<?
function GetFileParts($file_name)
{
$tmp = explode("/", $file_name);
$_filename = array_pop($tmp);
$tmp = explode(".", $_filename);
$ext = array_pop($tmp);
$fil = substr($_filename, 0, ((strlen($ext)+1) * -1));
$r = array();
$r["name"] = $fil;
$r["ext"] = $ext;
return $r;
}
$arquivo = "/folder/subfolder/nomedoarquivo.inc.php";
echo $arquivo . "<br/>";
echo "<pre>";
print_r(GetFileParts($arquivo));
echo "</pre>";
?>
nomedoarquivo.inc.php
Array
(
[name] => nomedoarquivo.inc
[ext] => php
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.