Find if a string starts and ends with another given string | PHP program to find if a given corner string is present at corners . ; If length of corner string is more , it cannot be present at corners . ; Return true if corner string is present at both corners of given string . ; Driver Code
< ? php function isCornerPresent ( $ str , $ corner ) { $ n = strlen ( $ str ) ; $ cl = strlen ( $ corner ) ; if ( $ n < $ cl ) return false ; return ( ! strcmp ( substr ( $ str , 0 , $ cl ) , $ corner ) && ! strcmp ( substr ( $ str , $ n - $ cl , $ cl ) , $ corner ) ) ; } $ str = " geeksforgeeks " ; $ corner = " geeks " ; if ( isCornerPresent ( $ str , $ corner ) ) echo ( " Yes " ) ; else echo ( " No " ) ; ? >