[ create a new paste ] login | about

Link: http://codepad.org/NQxuo1Vt    [ raw code | fork ]

k4st - PHP, pasted on Oct 7:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

$arr = array(
    'a', 'b', 'c', 'c', 'd','e', 'e',
    'e', 'e', 'e', 'f', 'e', 'f', 'e',
    'f', 'a', 'a', 'a', 'f', 'f', 'f',
);

$matches = array();
preg_match_all('~([a-f])(\1(\1*))?~', implode('', $arr), $matches, PREG_SET_ORDER);

foreach($matches as $match) {
    if(isset($match[3]))
        echo $match[1] . $match[1] .'<span style="color:red;">'. $match[3] .'</span>';
    else if(isset($match[2]))
        echo $match[2];
    else
        echo $match[1];
}


Create a new paste based on this one


Comments: