Forum Moderators: coopster

Message Too Old, No Replies

returning an array from a method

         

bleak26

3:46 pm on Feb 11, 2007 (gmt 0)

10+ Year Member



hi, could u tell me, is it possible to return an array from a method.
,would this be valid?

function get_data_for_blahblah(){

$db = new mysqli ('localhost', 'blahblah', 'blahblah', 'blahblah',3360,'blahblah');

$sqlstatement = "SELECT * from stuff";

$result1 = $db->query($sqlstatement);

$resultarray = $db->store_result();
return $resultarray;

}

eelixduppy

4:12 pm on Feb 11, 2007 (gmt 0)



Yes, it is perfectly valid to return arrays, however
$resultarray
is not an array, it is a mysqli result variable. You may have a problem with variable scope here if you are returning the result. Play around with it a bit; it may come down to pushing the results into an actual array before returning.