Finding sum of the segments used by each digit of the number
for ( $ i = 0 ; $ i < strlen ( $ s ) ; ++ $ i ) { $ count += $ seg [ ord ( $ s [ $ i ] ) - 48 ] ; } if ( $ count <= $ led ) return " YES " ; else return " NO " ; }