Return The Group For The Largest - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Return The Group For The Largest.php
- <?php
- function returnTheGroupForTheLargest($value, $group) {
- $result = array_filter($group, function($item) use ($value) {
- return $item['value'] >= $value;
- });
- if ($result) $result = array_values($result)[0];
- return $result;
- }
- $foo = [
- [
- 'id' => '1',
- 'value' => 1000,
- ],
- [
- 'id' => '2',
- 'value' => 2000,
- ],
- [
- 'id' => '3',
- 'value' => 3000,
- ],
- [
- 'id' => '4',
- 'value' => 4000,
- ],
- [
- 'id' => '5',
- 'value' => 5000,
- ],
- ];
- var_dump(returnTheGroupForTheLargest(1001, $foo));
File Description
- Return The Group For The Largest
- PHP Code
- 13 Oct-2021
- 611 Bytes
You can Share it:
Latest PHP Pastes