Cap0 Posted May 17, 2007 Share Posted May 17, 2007 Hi, How would i change this string: $str = "1005194" to: $str = "94510001" i've tried cutting each 2 numbers and stringreplacing then stringinserting, but it's just too confusing. Link to comment Share on other sites More sharing options...
BrettF Posted May 17, 2007 Share Posted May 17, 2007 Hi, How would i change this string: $str = "1005194" to: $str = "94510001" i've tried cutting each 2 numbers and stringreplacing then stringinserting, but it's just too confusing.So you want to take the bigest number in the string, shove at the start, then put it in reverse order? How are you trying to manipulate it? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
SoeMinnMinn Posted August 28, 2007 Share Posted August 28, 2007 Please try this function Func StringNumReverse($strVal, $num = 2) ;$strIn = "1005194" ;$strOut = "94510001" Local $strBase = $strVal Local $strTemp = "" Local $iCount = 0 Local $iRep = 0 Local $l = 0 If StringLen($strVal) < $num Then Return "" If StringLen($strVal) <> ((Int(StringLen($strVal)/ $num)) * $num) Then $iRep = $num - (StringLen($strVal) - ((Int(StringLen($strVal)/ $num)) * $num)) Else $iRep = 0 EndIf For $l = 1 To $iRep $strBase = "0" & $strBase Next $iCount = StringLen($strBase)/ $num For $l = 1 To $iCount $strTemp = $strTemp & StringMid($strBase, (StringLen($strBase) - ($l * $num) + 1), $num) Next Return $strTemp EndFunc $strIn = "1005194" $strOut = StringNumReverse($strIn, 2);"94510001";194005001 MsgBox(0, "", $strOut) Exit Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now