codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?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]; }
Private
[
?
]
Run code
Submit