I found the function submitted by jezndiatyahoodotcodotuk to be very helpful. I'm using PHP 5.2.5 and this function isn't defined, so it may depend on the ODBC driver being used.
The only problem with the solution already posted is that the return values don't match the ones specified by the documentation. I made the following modification so that the function will work the same whether it exists internally or not:
<?php
if (!function_exists('odbc_fetch_array')) {
function odbc_fetch_array($result, $rownumber=null) {
$array = array();
if (!($cols = odbc_fetch_into($result, $result_array, $rownumber))) {
return false;
}
for ($i = 1; $i <= $cols; $i++) {
$array[odbc_field_name($result, $i)] = $result_array[$i - 1];
}
return $array;
}
}
?>