Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

makeFilenameUnique()

Description

Make a filename unique by appending a dupe-string.

Parameters

ColumnTypeDefaultDescription
$base_values array
$filename string
$dupe_string string
$extension string
$dupe_increment int null

Return

string Unique filename

Location

include/collections_functions.php lines 3272 to 3286

Definition

 
function makeFilenameUnique($base_values$filename$dupe_string$extension$dupe_increment null)
    {
    
// Create filename to check if exist in $base_values
    
$check_filename $filename . ($dupe_increment $dupe_string $dupe_increment '') . '.' $extension;

    if(!
in_array($check_filename$base_values))
        {
        
// Confirmed filename does not exist yet
        
return $check_filename;
        }

    
// Recursive call this function with incremented value
    // Doing $dupe_increment = null, ++$dupe_increment results in $dupe_increment = 1
    
return makeFilenameUnique($base_values$filename$dupe_string$extension, ++$dupe_increment);
    }

This article was last updated 10th July 2020 00:35 Europe/London time based on the source file dated 9th July 2020 17:22 Europe/London time.