3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dbDownloads = array( 0 => array( "name" => "Xvid_Download.txt", "userId" => 1, "torrentId" => "4e1210f2469a7078eb0ecd6ef462d16f44d99837", "id" => 1 ), 1 => array( "name" => "Lol.mp4", "userId" => 2, "torrentId" => "e3811b9539cacff680e418124272177c47477157", "id" => 2 ), 2 => array( "name" => "Ubuntu-13.04.iso", "userId" => 1, "torrentId" => "c877dcecd3b14d02c0eccfd4e67a2cee71518405", "id" => 3 ), 3 => array( "name" => "NonDownload.lol", "userId" => 2, "torrentId" => "b7687dbbh8873dcc87464gf4387g78g7gf828887", "id" => 4 ) ); $clientTorrents = array( 0 => array( "hashString" => "4e1210f2469a7078eb0ecd6ef462d16f44d99837", "name" => "Xvid_Download.txt" ), 1 => array( "hashString" => "c877dcecd3b14d02c0eccfd4e67a2cee71518405", "name" => "Ubuntu-13.04.iso" ), 2 => array( "hashString" => "b7687dbbh8873dcc87464gf4387g78g7gf828887", "torrentname" => "NonDownload.lol" ), 3 => array( "hashString" => "e3811b9539cacff680e418124272177c47477157", "torrentname" => "Lol.mp4" ) ); $merged = array(); foreach ($clientTorrents as $clientTorrent) { /** Match $dbDownload::torrentId against clientTorrent::$hashString **/ $dbDownload = array_values(array_filter($dbDownloads, function($dbDownload) use($clientTorrent) { return $dbDownload['torrentId'] === $clientTorrent['hashString']; }))[0]; var_dump($clientTorrent); var_dump("<br /><br />"); var_dump($dbDownload); var_dump("<br /><br />---------------<br />"); }
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["hashString"]=> string(40) "4e1210f2469a7078eb0ecd6ef462d16f44d99837" ["name"]=> string(17) "Xvid_Download.txt" } string(12) "<br /><br />" array(4) { ["name"]=> string(17) "Xvid_Download.txt" ["userId"]=> int(1) ["torrentId"]=> string(40) "4e1210f2469a7078eb0ecd6ef462d16f44d99837" ["id"]=> int(1) } string(33) "<br /><br />---------------<br />" array(2) { ["hashString"]=> string(40) "c877dcecd3b14d02c0eccfd4e67a2cee71518405" ["name"]=> string(16) "Ubuntu-13.04.iso" } string(12) "<br /><br />" array(4) { ["name"]=> string(16) "Ubuntu-13.04.iso" ["userId"]=> int(1) ["torrentId"]=> string(40) "c877dcecd3b14d02c0eccfd4e67a2cee71518405" ["id"]=> int(3) } string(33) "<br /><br />---------------<br />" array(2) { ["hashString"]=> string(40) "b7687dbbh8873dcc87464gf4387g78g7gf828887" ["torrentname"]=> string(15) "NonDownload.lol" } string(12) "<br /><br />" array(4) { ["name"]=> string(15) "NonDownload.lol" ["userId"]=> int(2) ["torrentId"]=> string(40) "b7687dbbh8873dcc87464gf4387g78g7gf828887" ["id"]=> int(4) } string(33) "<br /><br />---------------<br />" array(2) { ["hashString"]=> string(40) "e3811b9539cacff680e418124272177c47477157" ["torrentname"]=> string(7) "Lol.mp4" } string(12) "<br /><br />" array(4) { ["name"]=> string(7) "Lol.mp4" ["userId"]=> int(2) ["torrentId"]=> string(40) "e3811b9539cacff680e418124272177c47477157" ["id"]=> int(2) } string(33) "<br /><br />---------------<br />"

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:
45.53 ms | 404 KiB | 8 Q