Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. <?php
  2. $data = ["rot","rot","schwarz","rot","rot","rot","schwarz"];
  3. $result = [];
  4. $keys =array_unique($data);
  5. foreach($keys as $key){
  6. $result[$key] = ['Abs'=>0,'Rel' =>0];
  7. }
  8.  
  9. foreach($data as $color){
  10. $result[$color]['Abs'] += 1;
  11. $result[$color]['Rel'] += 1/count($data);
  12. }
  13.  
  14. echo "<pre>";
  15. print_r($result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement