开发者

Changing the array return of php/mysql function

I have this get_all function:

function get_all($query)
{
    $res = mysql_query($query);
    $arr_res = array();
    while($row = mysql_fetch_array($res))
        $arr_res[] = $row;
    mysql_free_result($res);

    return $arr_res;
} 

It returns this array of data, which is what I need, but I don't want the first item of each array "[0]" to be returned with it:

   Array
    (
        [0] => Array
            (
                [0] => gallery-1-1310312288_logo.jpg
                [post_image] => gallery-1-1310312288_logo.jpg
            )

    )

How can I alter the function to drop this 开发者_StackOverflowextra item?


Change this line:

while($row = mysql_fetch_array($res, MYSQL_ASSOC))

By default mysql_fetch_array will return the numerical array index and the associative one - adding the second parameter will make the function only return the associate index.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜