fork(1) download
  1. <?php
  2.  
  3. $arr = array(1, 2, 3, 4, 5);
  4. function geomPr($b1, $q, &$arr) { // передача arr по ссылке
  5. $arr[1] = $b1;
  6. for ($n = 1; $n < 11; $n++) {
  7. if ($n == 1) {
  8. $b_previous = $b1;
  9. } else {
  10. $b_previous = $b_previous * $q;
  11. $b = $b_previous * $q;
  12. $arr[$n] = $b;
  13. }
  14. }
  15. };
  16.  
  17. geomPr(2, 2, $arr);
  18. print $arr[2];
Success #stdin #stdout 0.02s 23632KB
stdin
Standard input is empty
stdout
8