Functions (usually) take inputs and return outputs, like this:
Code:
The difference is that foo($barbar, $bazbaz) passes $barbar and $bazbaz in to the function. The function returns a value, which can be assigned to a variable (e.g. $result = foo($barbar, $bazbaz)). As the example function returns an array $result would be an array in this instance; however, using list() you can quickly extract values from an array:
Code:
Code:
Code:
The above three code snippets are functionally equivalent.
Code:
$out = foo($in);
The difference is that foo($barbar, $bazbaz) passes $barbar and $bazbaz in to the function. The function returns a value, which can be assigned to a variable (e.g. $result = foo($barbar, $bazbaz)). As the example function returns an array $result would be an array in this instance; however, using list() you can quickly extract values from an array:
Code:
list($scalar1, $scalar2) = foo($barbar, $bazbaz);
Code:
$result = foo($barbar, $bazbaz);
list($scalar1, $scalar2) = $result;
Code:
$result = foo($barbar, $bazbaz);
$scalar1 = $result[0];
$scalar2 = $result[1];
The above three code snippets are functionally equivalent.