How to add file extension to array of file names in PHP

1 Answer

0 votes
function addExtension($filename)
{
    return $filename.".php";
}
$filenames = ["index", "sitemap", "config", "signup"];
$filenames_with_extension = array_map("addExtension", $filenames);

print_r($filenames_with_extension);

/*

run:

Array ( [0] => index.php [1] => sitemap.php [2] => config.php [3] => signup.php ) 

*/

 



answered Nov 7, 2018 by avibootz

Related questions

...