json - Double names in PHP -


i have php code:

<?php     include 'imagem.php';     $imagem = new image(502, 500, '#ffffff');     $imagem->setfont('verdana', 14, '#fade45');      $helpers = json_decode(file_get_contents("http://api.formice.com/helper/online.json"));     foreach($helpers $server=>$list) {         $line = new line();         $line->margintop = 2;         $line->addtext(strtoupper($server) . ':', 'verdana bold', 12, '#009d9d');         $line->addlinebreak();         $line->addtext(implode(', ', $list), 'verdana', 12, '#6c77c1', 4);         $imagem->drawline($line);     }     $imagem->flushimg();  ?> 

and seems names duplicating because they're added twice in json file. can prevent via php, without modifying json file? enter image description here

$line->addtext(implode(', ', array_unique($list)), 'verdana', 12, '#6c77c1', 4); 

the function array_unique() gives ability remove duplicates arrays. in case $list contains same user twice, function remove them before imploding array.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -