How to get length of the longest sequence with same characters in a string?

Posted by SpawnCxy on Stack Overflow See other posts from Stack Overflow or by SpawnCxy
Published on 2010-05-10T15:16:30Z Indexed on 2010/05/10 15:24 UTC
Read the original article Hit count: 147

Filed under:
|
|

To be specified:

function getLength($str)
{
   //function i need
}
$str1 = 'aabbcccc'; 
$str2 = 'aabbccccaaaaa';
echo getLength($str1); //will get 4
echo getLength($str2); //will get 5

Any good ideas?Thanks in advance!

© Stack Overflow or respective owner

Related posts about php

Related posts about string