3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hostname = "lekkere.koekjes.men"; $certificates = json_decode('[{"commonName":"*.men"},{"commonName":"*.hans.nl"},{"commonName":"*.koekjes.men"}]'); $hostnameParts = explode(".", $hostname); foreach ($certificates as $certificate) { // commonName = *.lekkere.koekjes.men // hostname = www.lekkere.koekjes.men $commonName = $certificate->commonName; $commonNameParts = explode(".", $commonName); for ($i = 0; $i < max(count($commonNameParts), count($hostnameParts)); $i++) { $commonNamePart = count($commonNameParts) > ($i + 1) ? $commonNameParts[count($commonNameParts) - $i - 1] : null; $hostnamePart = count($hostnameParts) > ($i + 1) ? $hostnameParts[count($hostnameParts) - $i - 1] : null; if (! ( $commonNamePart === '*' || ($commonNamePart === null && $hostnamePart === 'www' && !in_array("*", $commonNameParts)) || ($commonNamePart === $hostnamePart) ) ) { continue 2; } } var_dump($certificate); }
Output for git.master, git.master_jit, rfc.property-hooks
object(stdClass)#3 (1) { ["commonName"]=> string(13) "*.koekjes.men" }

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:
63.02 ms | 401 KiB | 8 Q