Is there a simple way to convert a mysql query result object into an array (rather than an object?)

ie. say I run a query against a mysql database in order to show the results in a table:

$result= mysqli_query($link,$sql);
//...then run the result through the code that displays the table...that all works fine

BUT when I try to print_r($result) at the end of the process, all I see is the statement
"mysqli_result Object ( ) " is there a way to simply convert the object into something (ie an array) that can be used again for other purposes without re-running the query?

Thanks for any suggestions.

    There is a function for this:
    array = get_object_vars ( $object )
    [man]get_object_vars[/man]

      Joseph_Sliker wrote:

      is there a way to simply convert the object into something (ie an array)

      $array=(array)$object;

        While you can cast the returned MySQLi_Result object to an array, I don't think you'll find it to be of much use, as it does not by itself contain the actual query results.

        You will need to use the MySQLi_Result methods/functions to get the actual query results.

          Write a Reply...