计数行 [英] counting rows
本文介绍了计数行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从数据库得到了这样的结果:
user1
user1
user1
user2
user2
user1
user1
我怎么能算上这样的PHP :
用户1连续3个,然后user2连续2个,那么user1连续2个?
thanx
i got for example this result from data base:
user1
user1
user1
user2
user2
user1
user1
how can i count in php like that:
user 1 have 3 in a row ,then user2 have 2 in a row ,then user1 have 2 in a row?
thanx
推荐答案
比较相邻值,如果它们相同则计数,如果测试失败则将计数存储在某处。你必须组成一个合适的存储系统/变量。
问候
compare the adjacent values, count up if they are the same and store the count somewhere if the test fails. you have to make up a suited storage system/variable though.
regards
任何类似计数的短代码示例?
i没有得到你,对不起:(
tahnx
any short code example for counting like that?
i didn''t get you ,sorry :(
tahnx
之类的东西:
something like:
展开 | 选择 | Wrap | 行号
这篇关于计数行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文