ls(); $controllerList = $list[1]; // The list of the files in the controller directory // replace the text in $controllerList that matches the keys in the following array with the key's value: $removeEntries = array("_controller.php" => "", "controller_template.php" => "", "registrations_controller~.php" => ""); foreach($removeEntries as $key=>$value) { $controllerList = str_replace($key, $value, $controllerList); } $html = "\n"; echo $html; ?>