Skip to content
Advertisement

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

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

Advertisement

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).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement