text: PHP program to find the largest smaller number by swapping one digit . Returns largest possible number with one swap such that the number is smaller than str . It is assumed that there are leading 0 s .
code: < ? php function prevNum ( $ str ) { $ len = strlen ( $ str ) ; $ index = -1 ;