Snake case of a given sentence | Function to replace spaces and convert into snake case ; Converting space to underscor ; If not space , convert into lower character ; Driver Code ; Calling function
< ? php function convert ( $ str ) { $ n = strlen ( $ str ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { if ( $ str [ $ i ] == ' ▁ ' ) $ str [ $ i ] = ' _ ' ; else $ str [ $ i ] = strtolower ( $ str [ $ i ] ) ; } echo $ str ; } $ str = " I ▁ got ▁ intern ▁ at ▁ geeksforgeeks " ; convert ( $ str ) ; ? >