How can PHP functions like substr() and array_multisort() be leveraged to effectively sort alphanumeric strings based on custom criteria?

To effectively sort alphanumeric strings based on custom criteria, you can use PHP functions like substr() to extract specific portions of the strings for comparison and array_multisort() to sort them based on multiple criteria.

// Sample array of alphanumeric strings
$strings = array("abc123", "def456", "ghi789", "jkl101");

// Custom sorting criteria function
function customSort($a, $b) {
    $numA = (int) substr($a, 3); // Extract numbers from position 3 onwards
    $numB = (int) substr($b, 3);
    
    if ($numA == $numB) {
        return 0;
    }
    return ($numA < $numB) ? -1 : 1;
}

// Sort the array based on custom criteria
usort($strings, "customSort");

// Output the sorted array
print_r($strings);