Check if a string is suffix of another | PHP program to find if a string is suffix of another ; Driver Code ; Test case - sensitive implementation of endsWith function
< ? php function isSuffix ( $ s1 , $ s2 ) { $ n1 = ( $ s1 ) ; $ n2 = strlen ( $ s2 ) ; if ( $ n1 > $ n2 ) return false ; for ( $ i = 0 ; $ i < $ n1 ; $ i ++ ) if ( $ s1 [ $ n1 - $ i - 1 ] != $ s2 [ $ n2 - $ i - 1 ] ) return false ; return true ; } $ s1 = " geeks " ; $ s2 = " geeksforgeeks " ; $ result = isSuffix ( $ s1 , $ s2 ) ; if ( $ result ) echo " Yes " ; else echo " No " ; ? >