3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); function buildPosArr( $s, $d ) { $pArr = []; $needle = ""; $endstr = 0; for( $i=0, $max=count( $d ); $i < $max-1; $i++) { $needle = $d[$i]; if( ($pos = stripos( $s, $needle ) ) !== false){ $pArr[$pos] = $needle; if ($needle == "plain") break; // done for ( $j = $pos, $max = ($pos + strlen($needle)); $j < $max; $j++) { $s[$j] = "\0"; } // end for }// end if }// end for return $pArr; } function assign2str(&$s,$k,$v){ $max = strlen($v); for($i = $k, $j=0; $j < $max; $j++,$i++) { $s[$i] = $v[$j]; } } $str = "THERAININSPAINSTAYSMAINLYINTHEPLAIN."; echo "Before: $str\n\n"; $d = ["The", "rain", "in", "Spain", "stays", "mainly", "in", "the", "plain"]; $arr = buildPosArr( $str, $d ); foreach ($arr as $key => $value) { switch($value) { case "The": $value = strtolower($value); break; case "rain": $value = ucfirst($value); break; case "in": $value = ucfirst($value); case "Spain": break; case "stays": $value = strtoupper($value); break; case "mainly": break; case "plain": $value = ucfirst($value); default: break; } assign2str( $str,$key,$value ); } echo " After: ",$str;
Output for git.master, git.master_jit, rfc.property-hooks
Before: THERAININSPAINSTAYSMAINLYINTHEPLAIN. After: theRainInSpainSTAYSmainlyInthePlain.

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