Number of Larger Elements on right side in a string | PHP program to find counts of right greater characters for every character . ; Driver code
< ? php function printGreaterCount ( $ str ) { $ len = strlen ( $ str ) ; $ right = array_fill ( 0 , $ len , 0 ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { for ( $ j = $ i + 1 ; $ j < $ len ; $ j ++ ) if ( $ str [ $ i ] < $ str [ $ j ] ) $ right [ $ i ] ++ ; } for ( $ i = 0 ; $ i < $ len ; $ i ++ ) echo $ right [ $ i ] . " ▁ " ; } $ str = ' bcd ' printGreaterCount ( $ str ) ; ? >