dsyo9700 2012-04-13 12:25
浏览 9
已采纳

Count()返回的条目数不同于var_dump()

Hey guys I'm tired and can't figure this one out so any help would be appreciated.

I have an array called $Row that I get from database table.

When I run var_dump($Row); I get the following:

array
  0 => string '1' (length=1)
  'id' => string '1' (length=1)
  1 => string 'erik' (length=4)
  'username' => string 'erik' (length=4)
  2 => string 'd95eb19a15301089985ad6fd6ecbf2d7' (length=32)
  'password' => string 'd95eb19a15301089985ad6fd6ecbf2d7' (length=32)
  3 => string '' (length=0)
  'email' => string '' (length=0)
  4 => string '0' (length=1)
  'date_join' => string '0' (length=1)
  5 => string '0' (length=1)
  'date_mod' => string '0' (length=1)
  6 => string '1' (length=1)
  'active' => string '1' (length=1)
  7 => string '1' (length=1)
  'admin' => string '1' (length=1)
  8 => string '0' (length=1)
  'deleted' => string '0' (length=1)

When I run echo count($Row); I get value 18.

Count and var_dump are right next to each other, there is no modification of $Row.

Question: Why does Count() return 18 entried when there are only 8 of them inside $Row shown by var_dump()? I guess I just don't understand count()... I checked http://php.net/manual/en/function.count.php, but still don't get it...

Edit: I understand whats wrong know, thanks everyone. Another question. How can I remove the ones that are in a string, for instance I want this kind of a table:

array
  0 => string '1' (length=1)
  1 => string 'erik' (length=4)
  2 => string 'd95eb19a15301089985ad6fd6ecbf2d7' (length=32)
  3 => string '' (length=0)
  4 => string '0' (length=1)
  5 => string '0' (length=1)
  6 => string '1' (length=1)
  7 => string '1' (length=1)
  8 => string '0' (length=1)

* I'm using mysql_fetch_array() to retrieve the data and put it into a table.

  • 写回答

5条回答 默认 最新

  • dongru2019 2012-04-13 12:29
    关注

    You are having mixed array integer and associative and having 18 elements. This is I think returned from mysql_fetch_array which by default return associative and numeric indexed array.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并