3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tag($str,$pos1,$pos2) { $offset=-1; $arrs=explode("-",$str); list($pos1,$pos2)=array(min($pos1,$pos2),max($pos1,$pos2)); foreach($arrs as &$chunk) { $len=strlen($chunk); if($offset+1>$pos2) break; if($offset+1<=$pos2 && $offset+$len>=$pos2) { $chunk=substr($chunk,0,$pos2-$offset-1)."<span style='color:red'>".substr($chunk,$pos2-$offset-1,1)."</span>".substr($chunk,$pos2-$offset); } if($offset+1<=$pos1 && $offset+$len>=$pos1) { $chunk=substr($chunk,0,$pos1-$offset-1)."<span style='color:red'>".substr($chunk,$pos1-$offset-1,1)."</span>".substr($chunk,$pos1-$offset); } $offset+=$len; } return $arrs; } print_r(tag("55798-45366-11255-48084-35644-28027-85391-45536-85002-55350-4166-5991-0313-3681-9382-9143-2852-8142-8643-0235-875-383-839-92-91-00-81",5,8));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => 55798 [1] => <span style='color:red'>4</span>53<span style='color:red'>6</span>6 [2] => 11255 [3] => 48084 [4] => 35644 [5] => 28027 [6] => 85391 [7] => 45536 [8] => 85002 [9] => 55350 [10] => 4166 [11] => 5991 [12] => 0313 [13] => 3681 [14] => 9382 [15] => 9143 [16] => 2852 [17] => 8142 [18] => 8643 [19] => 0235 [20] => 875 [21] => 383 [22] => 839 [23] => 92 [24] => 91 [25] => 00 [26] => 81 )

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