Hi. I want to know the difference between two functions of php. One is mysql_fetch_array() and another one is mysql_fetch_object(). I want to know the basic difference between these two and how they are working? Please tell me friends. Thanks in advance.
From php.net: Note: mysql_fetch_object() is similar to mysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names). If you had a database with the first field as 'Name' and used both ways: $obj = mysql_fetch_object($result); $ary = mysql_fetch_array($result); You could display the value of 'Name' like this: echo $obj->Name; echo $ary[0]; echo $ary['Name']; Also from php.net: Performance: Speed-wise, mysql_fetch_object() is identical to mysql_fetch_array(), and almost as quick as mysql_fetch_row() (the difference is insignificant).
It's simple. First obe returns an array, and the second one returns an object http://www.php.net/mysql_fetch_array http://www.php.net/mysql_fetch_object Note the difference in examples: print $row->name; Code (markup): and print $row["name"]; Code (markup):