I don't think this is a good practice. You should use `$ids` for the array and then `$id` for the single element.

Also I don't see what are you trying to do here because you are processing a foreach without passing elements by reference. So you are doing all this to get the latest `$id` ? 

I guess you need something like:

```php
foreach ($ids as &$id) 
{
    $parts = explode(':', $id);
    $id = $parts[0]; 
}
```

You save the `substr_count()` and have a `$ids` array with the clean ids