Is there a specific syntax or structure to follow when returning multiple values from a PHP function using arrays?

When returning multiple values from a PHP function using arrays, you can create an associative array where each key represents a specific value. This allows you to easily access the returned values by their corresponding keys outside of the function. Simply assign the values to their respective keys in the array and return the array at the end of the function.

function getMultipleValues() {
    $value1 = 'First value';
    $value2 = 'Second value';
    
    $values = array(
        'key1' => $value1,
        'key2' => $value2
    );
    
    return $values;
}

// Usage example
$returnedValues = getMultipleValues();
echo $returnedValues['key1']; // Output: First value
echo $returnedValues['key2']; // Output: Second value