3v4l.org

run code in 300+ PHP versions simultaneously
<?php $main_domains = ['example.co.uk','example.com','example.org']; $sub_domains = ['sub.example.com','ftp.example.org','ftp.example.co.uk','mail.example.com']; $results = []; array_walk( $sub_domains, function($subdomain) use ($main_domains, &$results) { foreach ($main_domains as $domain) { // or however you're checking if (strpos($subdomain, $domain) !== false) { $results[$domain][] = $subdomain; } } } ); var_dump($results);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { ["example.com"]=> array(2) { [0]=> string(15) "sub.example.com" [1]=> string(16) "mail.example.com" } ["example.org"]=> array(1) { [0]=> string(15) "ftp.example.org" } ["example.co.uk"]=> array(1) { [0]=> string(17) "ftp.example.co.uk" } }

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:
61.87 ms | 402 KiB | 8 Q