It simple means that $cities[$counter]
is empty string. You need to add extra check before using substr_count function.
If you have for example code:
$array = array();
$array[] = '';
array will have one element, but when you use this element in substr_count function it will raise warning