The database stores records (user’s friends) in the form:
qwerty1,qwerty2
This is an array that stores users. How to count the number of users in it?
You can try this:
$friends = "f1,f2,f3"; $countFriends = count(explode(',', $friends)); echo $countFriends;
It is possible this way: we have a line separated by commas, so the number of words is the number of commas + 1
Here is the implementation
len(value) - len(replace(value,',','')) + 1
Source: https://ru.stackoverflow.com/questions/314775/
All Articles