For each result in MySQL query, push to array (complicated)

后端 未结 3 1185
感情败类
感情败类 2021-01-29 00:45

Okay, here\'s what I\'m trying to do. I am running a MySQL query for the most recent posts. For each of the returned rows, I need to push the ID of the row to an array, then wit

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 01:14

    I tend to like:

    $posts = array();
    while ($row = mysql_fetch_array($result)) {
        $posts[] = array(
             'id' => $row['id'],
             'title' => $row['title'],
             'text' => $row['text']
        );
    }
    

提交回复
热议问题