fork download
  1. <?php
  2. class LowerThanFilter
  3. {
  4. private $limit;
  5.  
  6. // $key is an optional parameter
  7. function __construct($limit, ?string $key = null)
  8. {
  9. $this->limit = $limit;
  10. $this->key = $key;
  11. }
  12.  
  13. function __invoke($i)
  14. {
  15. // if $key is set, compare with key
  16. if (!is_null($this->key)) {
  17. return $i[$this->key] <= $this->limit;
  18. }
  19. return $i <= $this->limit;
  20. }
  21. }
  22. $followers = [["latest_reel_media" => 1], ["latest_reel_media" => 100]];
  23. $followers = array_filter($followers, new LowerThanFilter(50, 'latest_reel_media'));
  24. var_dump($followers);
  25. // your code goes here
Success #stdin #stdout 0.02s 82560KB
stdin
Standard input is empty
stdout
array(1) {
  [0]=>
  array(1) {
    ["latest_reel_media"]=>
    int(1)
  }
}