Remove Duplicates from SHOUTcast script print_r ($vc_shoutcast->LISTENERS);

58 views Asked by At

Using https://github.com/VosCast/SHOUTcast-PHP-Stats Trying to get the listeners to not repeat. Have tried several examples I found on Stack Overflow but for some reason I'm missing something.

Array
        (
            [0] => Array
                (
                    [HOSTNAME] => 138.201.220.32
                    [USERAGENT] => WinampMPEG/5.50
                    [CONNECTTIME] => 558295
                    [UID] => 32332328
                    [TYPE] => 17
                    [REFERER] => Array
                        (
                        )

                    [XFF] => Array
                        (
                        )

                    [GRID] => 32332328
                    [TRIGGERS] => 0
                )

            [1] => Array
                (
                    [HOSTNAME] => 96.236.90.120
                    [USERAGENT] => Dalvik/1.6.0 (Linux; U; Android 4.1.2; DROID RAZR Build/9.8.2O-72_VZW-16-5)
                    [CONNECTTIME] => 550178
                    [UID] => 32348000
                    [TYPE] => 1
                    [REFERER] => Array
                        (
                        )

                    [XFF] => Array
                        (
                        )

                    [GRID] => 32348000
                    [TRIGGERS] => 0
                )

            [2] => Array
                (
                    [HOSTNAME] => 99.101.170.6
                    [USERAGENT] => Wget/1.11.4
                    [CONNECTTIME] => 329039
                    [UID] => 32803132
                    [TYPE] => 33554432
                    [REFERER] => Array
                        (
                        )

                    [XFF] => Array
                        (
                        )

                    [GRID] => 32803132
                    [TRIGGERS] => 0
                )

            [3] => Array
                (
                    [HOSTNAME] => 99.101.170.6
                    [USERAGENT] => Wget/1.11.4
                    [CONNECTTIME] => 329039
                    [UID] => 32803134
                    [TYPE] => 33554432
                    [REFERER] => Array
                        (
                        )

                    [XFF] => Array
                        (
                        )

                    [GRID] => 32803134
                    [TRIGGERS] => 0
                )

            [4] => Array
                (
                    [HOSTNAME] => 99.101.170.6
                    [USERAGENT] => Wget/1.11.4
                    [CONNECTTIME] => 329038
                    [UID] => 32803138
                    [TYPE] => 33554432
                    [REFERER] => Array
                        (
                        )

                    [XFF] => Array
                        (
                        )

                    [GRID] => 32803138
                    [TRIGGERS] => 0
                )

            [5] => Array
                (
                    [HOSTNAME] => 99.101.170.6
                    [USERAGENT] => Wget/1.11.4
                    [CONNECTTIME] => 329038
                    [UID] => 32803140
                    [TYPE] => 33554432
                    [REFERER] => Array
                        (
                        )

                    [XFF] => Array
                        (
                        )

                    [GRID] => 32803140
                    [TRIGGERS] => 0
                )

          [6] => Array
                (
                    [HOSTNAME] => 92.117.146.148
                    [USERAGENT] => Kodi/17.6 (Linux; Android 7.1.2; AFTMM Build/NS6280) Android/7.1.2 Sys_CPU/armv7l App_Bitness/32 Version/17.6-Git:20171114-a9a7a20
                    [CONNECTTIME] => 108
                    [UID] => 33414641
                    [TYPE] => 1
                    [REFERER] => Array
                        (
                        )

                    [XFF] => Array
                        (
                        )

                    [GRID] => 33414641
                    [TRIGGERS] => 0
                )

        )




//works but repeats the same HOSTNAMES

print_r(array_unique(($vc_shoutcast->LISTENERS), SORT_LOCALE_STRING));
1

There are 1 answers

0
Alex Paramonov On

It is possible for Shoutcast to have several connected listeners from the same IP, so that is not a problem. If you want to remove duplicated IP addresses - just use any PHP code that will clean array from duplicates, there are a lot of examples out there.