protected static function iterateFileName(string $fileName)
    {
        //First remove Extension
        $arrFileParts = explode(".", $fileName);
        $extension = array_pop($arrFileParts);
        $tempFileName = implode(".", $arrFileParts);
        $arrFileName = explode("_", $tempFileName);
        if (is_numeric($arrFileName[(count($arrFileName) - 1)])) {
            $iterator = (int) array_pop($arrFileName);
            $iterator++;
            $arrFileName[] = $iterator;
            $newFileName = implode("_", $arrFileName);
            return $newFileName . "." . $extension;
        }
        return $tempFileName."_1." . $extension;
    }
protected static function iterateFileName(string $fileName)
    {
        //First remove Extension
        $arrFileParts = explode(".", $fileName);
        $extension = array_pop($arrFileParts);
        $tempFileName = implode(".", $arrFileParts);
        $arrFileName = explode("_", $tempFileName);
        if (is_numeric($arrFileName[(count($arrFileName) - 1)])) {
            $iterator = (int) array_pop($arrFileName);
            $iterator++;
            $arrFileName[] = $iterator;
            $newFileName = implode("_", $arrFileName);
            return $newFileName . "." . $extension;
        }
        return $tempFileName."_1." . $extension;
    }
protected static function iterateFileName ( string $ fileName ) { //First remove Extension $ arrFileParts = explode ( "." , $ fileName ) ; $ extension = array_pop ( $ arrFileParts ) ; $ tempFileName = implode ( "." , $ arrFileParts ) ; $ arrFileName = explode ( "_" , $ tempFileName ) ; if ( is_numeric ( $ arrFileName [ ( count ( $ arrFileName ) - 1 ) ] ) ) { $ iterator = ( int ) array_pop ( $ arrFileName ) ; $ iterator ++ ; $ arrFileName [ ] = $ iterator ; $ newFileName = implode ( "_" , $ arrFileName ) ; return $ newFileName . "." . $ extension ; } return $ tempFileName . "_1." . $ extension ; }
Puts a number on the end of a file name, prevents overwriting
@param string $fileName
@return string
Puts a number on the end of a file name prevents overwriting