Php Programming Code Examples
Php > Arrays Code Examples
Call by reference and multidimensional arrays.
Call by reference and multidimensional arrays.
<?
function GetDBRows ($result, $data)
{
$rows = pg_NumRows($result);
$fields = pg_NumFields($result);
for ($i = 0; $i < $rows; $i++)
{
for ($k = 0; $k < $fields; $k++)
{
$tmp = pg_result($result, $i, $k);
$data[$i][$k] = "$tmp";
}
}
}
$c = pg_connect("...");
$result = pg_exec($c, "select ...");
GetDBRows($result, &$foo);
while ($array = current($foo))
{
while ($string = current($array))
{
echo $string . "\n";
next($array);
}
next($foo);
}
?>