Count duplicate element of an array in PHP without using in-built function