<?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 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- 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
)
- Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/On0a0 on line 7
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/On0a0 on line 7
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/On0a0 on line 7
Process exited with code 255.
preferences:
316.28 ms | 401 KiB | 459 Q