mysql_fetch_array只有字符串数组键 [英] mysql_fetch_array and only string array keys

查看:102
本文介绍了mysql_fetch_array只有字符串数组键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试的print_r一个SQL查询mysql_fetch_array,我得到这样的结果。

 阵列

    [0] => 1
    [ID] => 1
    [1] => 2011
    [出版日期] => 2011
    [2] =>发布
    [现状] =>发布
    [3] =>测试
    [POST_TITLE] =>测试
    [4] => &安培; NBSP;暴躁测试测试testtttttt
    [POST_TEXT] => &安培; NBSP;暴躁测试测试testtttttt
    [5] =>真正
    [post_comments] =>真正
    [6] => 21
    [评论] => 21
    [7] => 1
    [NETWORK_ID] => 1
    [8] => 3
    [观点] => 3
    [9] => 0
    [评论] => 0

我要的仅仅是字符串数组键,​​以便我怎么能这样的结果转换为?

 阵列

    [ID] => 1
    [出版日期] => 2011
    [现状] =>发布
    [POST_TITLE] =>测试
    [POST_TEXT] => &安培; NBSP;暴躁测试测试testtttttt
    [post_comments] =>真正
    [评论] => 21
    [NETWORK_ID] => 1
    [观点] => 3
    [评论] => 0


解决方案

使用的 mysql_fetch_assoc

When I try to print_r mysql_fetch_array of a sql query, I get this result.

Array
(
    [0] => 1
    [id] => 1
    [1] => 2011
    [publish_date] => 2011
    [2] => Posted
    [status] => Posted
    [3] => test
    [post_title] => test
    [4] =>  testy test test testtttttt
    [post_text] =>  testy test test testtttttt
    [5] => true
    [post_comments] => true
    [6] => 21
    [reviews] => 21
    [7] => 1
    [network_id] => 1
    [8] => 3
    [views] => 3
    [9] => 0
    [comments] => 0
)

All I want is only string array keys so how can I convert this result to that?

Array
(
    [id] => 1
    [publish_date] => 2011
    [status] => Posted
    [post_title] => test
    [post_text] =>  testy test test testtttttt
    [post_comments] => true
    [reviews] => 21
    [network_id] => 1
    [views] => 3
    [comments] => 0
)

解决方案

Use mysql_fetch_assoc

这篇关于mysql_fetch_array只有字符串数组键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆