CLICK HERE FOR FREE BLOGGER TEMPLATES, LINK BUTTONS AND MORE! »

Thursday, March 31, 2011

menukar ayat ke title case -Coldfusion function

Credit to : http://www.easycfm.com/coldfusion/forums/viewmessages.cfm?Forum=28&Topic=12751

<cffunction name="titleCase" access="public" returntype="string">
     <cfargument name="str" type="string" required="yes" />

     <cfset var retStr = "" />
     <cfset var idx = "" />

        <cfloop list="#arguments.str#" delimiters=" " index="idx">
          <cfset retStr = listAppend(retStr, ucase(left(idx,1)) & lcase(right(idx,Len(idx)-1))) />
        </cfloop>

     <cfreturn retStr />
</cffunction>
<cfset v = titleCase("selamat datang siti")>
<cfset v =  REReplace(#v#,","," ","ALL") >
<cfoutput>#v#</cfoutput>

outputnya :
Selamat Datang Siti

3 comments:

iera

thnks kak mas sbb membantu.hihihi

HaiRe

power la masita... power rangers pun dah kalah nie...

aku la...

ceh..mana de power..power meniru ye la...

Post a Comment