Depends on what you want to work with.
To get the user IDs into an array, I would use
$arr = explode(',', $userIDs);
$arr = array_map('trim', $arr);
To traverse the string, you can use
$len = strlen($userIDs);
for($i = 0; $i < $len; $i++){
$char = $userIDs[$i];
// do something with it
}