PHP class return multiple arrays independently from various functions -



PHP class return multiple arrays independently from various functions -

i starting work php classes , have next need:

i want create class have 2 functions returning 1 array each. 2 arrays can used either withing class (by other functions) or outside class. how homecoming 3 arrays?

what tried have other functions homecoming array value, can utilize outside. efficient way? there improve , quicker way homecoming arrays independently?

so far have this:

class playersdata { private $players = array(); private $resultados = array(); public function myplayers () { homecoming $this->players(); } public function playersquery { $query = "select * scoreboard"; $playersquery = $con->prepare($query); $playersquery->execute(); $this->players = $playersquery->fetchall(pdo::fetch_assoc); } function checkpartidos { $queryresultados = "select * partidos ganador <> 0"; $result = $con->prepare($queryresultados); $result->execute(); $this->$resultados = $result->fetchall(pdo::fetch_assoc); }

you can't homecoming 3 values @ same time. in case of variables can use:-

return $a.'|'.$b.'|'.$c;

then explode string |.

in case of arrays can use:-

function testfunction() { $newarray = array(); $newarray[] = array('a1', 'a2'); $newarray[] = array('b1', 'b2'); homecoming $newarray; }

create dynamic array of arrays , homecoming one. please try.

php arrays function class return

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -