How to access the elements of a function's return array?

Solution 1:

You can add array keys to your return values and then use these keys to print the array values, as shown here:

function data() {
    $out['a'] = "abc";
    $out['b'] = "def";
    $out['c'] = "ghi";
    return $out;
}

$data = data();
echo $data['a'];
echo $data['b'];
echo $data['c'];

Solution 2:

you can do this:

list($a, $b, $c) = data();

print "$a $b $c"; // "abc def ghi"