How to pass an array into a function, and return the results with an array

后端 未结 9 1409
你的背包
你的背包 2021-02-05 07:25

So I\'m trying to learn how to pass arrays through a function, so that I can get around PHP\'s inability to return multiple values. Haven\'t been able to get anything to work so

9条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 08:15

    i know a Class is a bit the overkill

    class Foo
    {
    
     private $sum = NULL;
    
     public function __construct($array)
     {
       $this->sum[] = $array;
       return $this;
     }
    
     public function getSum()
     {
       $sum = $this->sum;
       for($i=0;$igetSum();
    

提交回复
热议问题