How do i assign the successive duplicate values of a string? PHP [closed]

Tags: , , ,



How do i assign the successive duplicate values of a string in a single offset of an array In PHP. For example FFF2AA

In array it should be

0=>FFF
1=>2
2=AA

In array format

Answer

This post Count consecutive occurence of specific, identical characters in a string – PHP gives you almost your perfect answer. you just have tu use ‘*’ instead of ‘+’ in the regex if you want to take into accounts 1 character strings (like the ‘2’ above).



Source: stackoverflow