php foreach with multidimensional array

后端 未结 12 1621
一向
一向 2020-11-27 05:10

I\'m developing a php app that uses a database class to query mySQL.

the class is here: http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/

12条回答
  •  难免孤独
    2020-11-27 05:38

    Example with mysql_fetch_assoc():

    while ($row = mysql_fetch_assoc($result))
    {
        /* ... your stuff ...*/
    }
    

    In your case with foreach, with the $result array you get from select():

    foreach ($result as $row)
    {
        /* ... your stuff ...*/
    }
    

    It's much like the same, with proper iteration.

提交回复
热议问题