This article explains the return value of the PHP function returned from the learning experience.
Returns a value inside the function with return or NULL to end the function's run. However, when you return an array, you can also use Print_r directly inside the function to print. But generally do not do so.
Take an example of an article:
can also be implemented as follows:
<span style= "Font-family:microsoft yahei;font-size:14px;" ><? PHP function Bubble ($array) { $len = count ($array); if ($len <= 1) {return $array;} for ($i = 0; $i < $len; $i + +) {for ($j = $len-1; $j > $i; $j-) { if ($array [$j] < $array [$j-1]) { $tmp = $ar ray[$j]; $array [$j] = $array [$j-1]; $array [$j-1] = $tmp; } } } Print_r ($array); } $array =array (' A ', ' B ', ' C ', ' e ', ' d ', ' G ', ' f '); Bubble ($array); ? ></span>
However, it is better to use the previous article when invoking this:
<span style= "Font-family:microsoft yahei;font-size:14px;" > $a =bubble ($array); Print_r ($a);</span>
Return a little usage of the array in PHP