How can PHP functions return multiple values and how can they be accessed?

PHP functions can return multiple values by using an array or an object to store and return the values. To access these values, you can assign the return value of the function to a variable and then access the individual values using array or object syntax.

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

// Assign the return value of the function to a variable
$returnedValues = getMultipleValues();

// Access individual values using array syntax
echo $returnedValues[0]; // Output: First value
echo $returnedValues[1]; // Output: Second value