I'm trying to count frequency from input data.
Here is e.g input including Y value / X value / User Key
Y:5, X:3, User:A
Y:12, x:1, User:B
Y:66, X:2, User:A
Y:180, X:3, User:C
Y:328, X:4, User:D
Y:549, X:3, User:D
Y:765, X:2, User:A
Most important value is Y. I want to count each user's number of frequency each user have.
- Y : 1~100
- Y : 100~500
- Y : 500~1000
I want this output of the counts of each user value like this :
(Each [value] will be used to insert to database)
[User Key] [Total counting] [1~100] [100~500] [500~1000]
User [A] have [3] data, [2] [0] [1]
User [B] have [1] data, [1] [0] [0]
User [C] have [1] data, [0] [1] [0]
User [D] have [2] data, [0] [1] [1]
I tried simply divide data to rows like this :
foreach ($input as $row) {
echo substr(strstr( $row, 'User:'), 5)
}
And I don't have any idea to count each Users. I'm still learning, and I would appreciate your help.