this is my first post here, in the past I found all my questions already solved. Not this time so please help me :-)!
- Why is
$returned_assoc_arrholding an index based array instead of the associative? - I also tried it with a reference
public function &fetch_assoc($res)but without luck? - Is there any way to fix this? I really need this to be an associative array..
I hope I explained everything quite well and some Senior PHP Coders can help with this.
Here we go with the code snippets:
file1.php
public function fetch_assoc($res) {
$assoc_arr = mysql_fetch_assoc($res);
echo "<pre>";
print_r($assoc_arr);
echo "</pre>";
return $assoc_arr;
}
file2.php
$returned_assoc_arr = $foo->fetch_assoc($res);
echo "<pre>";
print_r($returned_assoc_arr);
echo "</pre>";
Output from file2.php:
Array
(
[id] => 42
[Client] => 1
[DebtorAccountNumber] => 1234512345
[OrderDate] => 2001-04-03 02:00:00
[Status] => 1
[Comment] => this is a comment
[CreatedBy] => 1
[Reference] => 2083137729
)
Array
(
[0] => 42
[1] => 1
[2] => 1234512345
[3] => 2001-04-03 02:00:00
[4] => 1
[5] => this is a comment
[6] => 1
[7] => 2083137729
)