Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. Use array_count_values() to count the number of times each value appears in the array.
  2. Use array_filter() to get the values that occur once in the array.
  3. And finally use array_keys() to get the value from the array.
  4.  
  5. example code in PHP
  6.  
  7. <?php
  8. $marks = [12,13,13,14,12,15,15];
  9. $result = array_keys(array_filter(array_count_values($marks), function($v)
  10. {
  11. return $v == 1;
  12. } ));
  13. print_r($result);
  14. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement