PHP 8.4.24 Released!

Voting

: three plus four?
(Example: nine)

The Note You're Voting On

lincoln dot mahmud at gmail dot com
5 years ago
Get Group match letter

<?php 

$s= 'aaabbbcceeffaaeeeaaabbzmmm';

function groupby( $s ){
    static $a = [];
    static $i = 0;
    
    $o = strspn( $s, $s[$i], $i);
    $a[ $i ] = [  $s[$i] => $o ];
    $i += $o;
    
    if( $i < strlen($s) ) {
        groupby($s);
    }

    return $a;
}

print_r(groupby($s));

?>

<< Back to user notes page

To Top