-1

I have this code inside a PHP function:

$results = array();
    while($result = mysql_fetch_array($rs)) {
        $results[] = $result;   
        //echo $result["company"].'<br>';
    }
    return $results;

then outside of the function, i use:

$table = 'customer';
$array = pages($table);
foreach($array as $ret) {
    //display here...
}

i want to return some extra HTML code at the end of my function to display a HTML table

how can i do this?

user2710234
  • 3,177
  • 13
  • 36
  • 54

2 Answers2

1

Quick solution: Use list():

function returnTwoResults()
{
    $res1 = 'foo';
    $res2 = 'bar';
    return array($res1, $res2);
}

list($foo, $bar) = returnTwoResults();

// $foo is 'foo', $bar is 'bar' now.

Quality solution: Work object-oriented and return an object that suits the context.

lxg
  • 12,375
  • 12
  • 51
  • 73
1

as an alternative you could

return array("results" => $results, "extra" => $extra);
mech
  • 617
  • 6
  • 16