1

I want to fetch values from a table in a MySQL database into PHP.

What kind of array will mysql_fetch_array($result) return? Associative or numeric?

2
  • 1
    Easily answered by testing it out yourself or checking the manual, right? Commented Oct 21, 2011 at 6:36
  • did you try a var_dump ? Commented Oct 21, 2011 at 6:37

3 Answers 3

4

array mysql_fetch_array ( resource $result [, int $result_type = MYSQL_BOTH ] )

It depends on the second parameter which is default MYSQL_BOTH and could be MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH.

More info about mysql_fetch_array.

Sign up to request clarification or add additional context in comments.

Comments

3

From the manual:

mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both

2 Comments

Did you read the manual yourself? Compare with xdazz's answer
@WesleyMurch if that's the case, I agree. Because it's typo and it's my fault.
1

It returns an array with both numeric and string indexes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.