3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'III.OOO.OOO.OOO.S'; $search = 'XXX'; $replace = 'B'; //replace ONLY FIRST occurance of "OOO" with "B" echo substr_replace($string,$replace,0,strlen($search)); //$string => B.OOO.OOO.S echo "\n---\n"; //replace ONLY LAST occurance of "OOOO" with "B" echo substr_replace($string,$replace,strrpos($string,$search),strlen($search)); //$string => OOO.OOO.B.S echo "\n---\n"; //replace ONLY LAST occurance of "OOOO" with "B" echo strrev(implode(strrev($replace),explode(strrev($search),strrev($string),2))); //$string => OOO.OOO.B.S
Output for git.master, git.master_jit, rfc.property-hooks
B.OOO.OOO.OOO.S --- B.OOO.OOO.OOO.S --- III.OOO.OOO.OOO.S

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.27 ms | 401 KiB | 8 Q