Advertisement
ericariyanto

Grouping data with same value in array PHP

Apr 4th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.28 KB | None | 0 0
  1. // grouping array data with same value
  2.  
  3. // this is sample data
  4. $data   = array('1','4','7','4','3','5','1','4');
  5.  
  6. //process for grouping data with same value
  7. foreach($data as $rows=>$val){
  8.     @$hasil[$val][] = $val;
  9. }
  10.  
  11. //output
  12. print_r($hasil);
  13.  
  14. //follow me : @ericariyanto
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement