3v4l.org

run code in 300+ PHP versions simultaneously
<?php $categories = array('Movie'); $reviews = array( array('category' => 'Movie'), array('category' => 'Movie'), array('category' => 'Movie'), array('category' => 'Movie'), array('category' => 'Game') ); print_r($reviews); // The issue WAS I'm not use ($categories) here... $filtered = array_filter($reviews, function($review) { return in_array($review['category'], $categories) === NULL; }); print_r($filtered);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [category] => Movie ) [1] => Array ( [category] => Movie ) [2] => Array ( [category] => Movie ) [3] => Array ( [category] => Movie ) [4] => Array ( [category] => Game ) ) Warning: Undefined variable $categories in /in/mZYTf on line 17 Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /in/mZYTf:17 Stack trace: #0 /in/mZYTf(17): in_array('Movie', NULL) #1 [internal function]: {closure}(Array) #2 /in/mZYTf(16): array_filter(Array, Object(Closure)) #3 {main} thrown in /in/mZYTf on line 17
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.5 ms | 402 KiB | 8 Q