3v4l.org

run code in 300+ PHP versions simultaneously
<?php $books_sorted = array( 0 => array( "title" => "In Search of Lost Time", "count" => 2 ), 1 => array( "title" => "Don Quixote" ), 2 => array( "title" => "The Great Gatsby" ) ); $books_available = array( 0 => array( "title" => "Moby Dick", "count" => 1 ), 1 => array( "title" => "In Search of Lost Time", "count" => 3, ), 2 => array( "title" => "The Great Gatsby", "count" => 7 ), 3 => array( "title" => "War and Peace", "count" => 9 ) ); $sorted_titles = array_column($books_sorted, 'title'); $available_titles = array_reduce($books_available, function($result, $e) { $result[$e['title']] = $e; return $result; }); $third_array = array_merge( array_map( function($e) use ($available_titles) { return array_merge($available_titles[$e['title']], $e); }, array_filter($books_sorted, function($e) use ($available_titles) { return in_array($e['title'], array_keys($available_titles)); }) ), array_filter($books_available, function($e) use ($sorted_titles) { return !in_array($e['title'], $sorted_titles); }) ); print_r($third_array);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [title] => In Search of Lost Time [count] => 2 ) [1] => Array ( [title] => The Great Gatsby [count] => 7 ) [2] => Array ( [title] => Moby Dick [count] => 1 ) [3] => Array ( [title] => War and Peace [count] => 9 ) )

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:
20.08 ms | 406 KiB | 5 Q