modelo_de_array_filter_multidimencional - 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 modelo_de_array_filter_multidimencional.php
- <?php
- $foo = [
- [
- 'id' => '1',
- 'value' => 1000,
- ],
- [
- 'id' => '2',
- 'value' => 2000,
- ],
- [
- 'id' => '3',
- 'value' => 3000,
- ],
- [
- 'id' => '4',
- 'value' => 4000,
- ],
- [
- 'id' => '5',
- 'value' => 5000,
- ],
- ];
- $valor = 1500;
- $result = array_filter($foo, function($item) use ($valor) {
- return $item['value'] <= $valor;
- });
- var_dump($result);