Thursday, 28 August 2014

Array filter with Implode process - PHP

 Array filter with Implode process :

<?php
$chat_list=array(0,1,2,3,4,5,0,4,2,3);  // This array have duplicates

$user=array();

foreach($chat_list as $key=>$chat)
{
 $user[$key]=$chat['UserName'];
}

 print_r(implode(' , ',array_unique($user))); //This will show unique and added comma for each element.

 ?>

No comments:

Post a Comment

KISS, DRY, SOLID, YAGNI — A Simple Guide to Some Principles of Software Engineering and Clean Code

1 — KISS (Keep It Simple, Stupid)  Simplicity triumphs over complexity. Direct and clear codes are better for developing, maintaining, and s...