3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rgba = 'rgba(80,80,80,0.5)'; function blendChannels(float $alpha, int $channel1, int $channel2): int { // blend 2 channels return intval(($channel1 * $alpha) + ($channel2 * (1.0 - $alpha))); } function convertRGBAtoHEX6(string $rgba): string { // sanitize $rgba = strtolower(trim($rgba)); // check if (substr($rgba, 0, 5) != 'rgba(') { return $rgba; } // extract channels $channels = explode(',', substr($rgba, 5, strpos($rgba, ')') - 5)); // compute rgb with white background $alpha = $channels[3]; $r = blendChannels($alpha, $channels[0], 0xFF); $g = blendChannels($alpha, $channels[1], 0xFF); $b = blendChannels($alpha, $channels[2], 0xFF); return sprintf('#%02x%02x%02x', $r, $g, $b); } echo convertRGBAtoHEX6($rgba);
Output for git.master, git.master_jit, rfc.property-hooks
#a7a7a7

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:
25.56 ms | 405 KiB | 5 Q