You would need to loop through the array and pull each unique user name into a new array, on encountering a duplicate you will update the value for that username. Something like this:
<?php
$string = 'name1,name2,name2,name4,name1,name5,name11,name6,name7,name7';
$array = explode(',', $string);
$tracking_array = Array();
foreach ($array as $value) {
if (! array_key_exists($value, $tracking_array)) {
$tracking_array[$value] = 1;
} else {
++$tracking_array[$value];
}
}
?>
This is quite a messy way of doing it though. If possible I would recommend that you create a separate table which will keep track of all views for all images and the users who viewed them. You can use an integer ID to to identify the user an the image viewed. This is a suggested implementation:
[size=3]stalkers table[/size]
[b]ViewID[/b]
UserId
PictureId
[size=3]pictures table[/size]
[b]ImageId[/b]
ImageName
ImageLocation
[size=3]users table[/size]
[b]UserId[/b]
UserName
Biobraphy
You can then use a simple query to extract how often an image has been viewed:
SELECT UserName,Count(*) Views FROM