Passing mysql_fetch_array to array ()

how can i pass mysql_fetch_array () to array ()

+3
source share
4 answers

You meant:

$variable = mysql_fetch_array($result); //$variable is now an array
+5
source

If you want to use it for multiple results, you might want to assign a while statement inside. For example,

$query = mysql_query("SELECT * FROM users");
$resultSet = array();
while($result = mysql_fetch_array($query))
{
    $resultSet[] = $result;
}
+15
source

Shorter version for adding multiple results to an array with while statement

while($r[]=mysql_fetch_array($query));
array_pop($r); // mysql_fetch_array() moves the internal data pointer ahead so last row should be cut off
+4
source

mysql_fetch_array () is just a function that outputs an array, so you can just attach it to any variable, for example:

$foo = mysql_fetch_array($bar);
0
source

Source: https://habr.com/ru/post/1726576/


All Articles