What are the advantages of using arrays to return multiple values compared to individual return statements in PHP functions?

Using arrays to return multiple values in PHP functions is advantageous compared to individual return statements because it allows you to easily return multiple pieces of data in a structured way. This can make your code cleaner and more organized, as all the values are grouped together in one return statement. Additionally, using arrays can make it easier to handle and manipulate the returned values in the calling code.

function getMultipleValues() {
    $value1 = 10;
    $value2 = "Hello";
    $value3 = true;

    return array($value1, $value2, $value3);
}

// Usage
$values = getMultipleValues();
echo $values[0]; // Output: 10
echo $values[1]; // Output: Hello
echo $values[2]; // Output: 1 (true)