Page 1 of 1 1
Topic Options
#208981 - 2014-06-03 08:26 PM String help
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Say you have the following two strings

$String1 = "ABCDEF"
$String2 = "1234567890"

and you want the output to be "A1B2C3D4E5F67890"

Usually $string2 will be longer than $string1.

How can you do this?


Edited by Allen (2014-06-04 12:51 AM)

Top
#208983 - 2014-06-03 08:38 PM Re: String help [Re: dataspike]
Allen Moderator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4314
Loc: USA
Completely untested, just typed in the box, but this should give you an idea...

 Code:
$String1 = "ABCDEF"
$String2 = "1234567890"

if len($string1)>len($string2)
  $loops=len($string1)
else
  $loops=len($string2)
endif

for $i=1 to $loops
  $newstring=$newstring + substr($string1,$i,1) + substr($string2,$i,1)
next

? $newstring

Top
#208984 - 2014-06-03 08:56 PM Re: String help [Re: Allen]
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Nevermind...
Top
#208985 - 2014-06-03 08:58 PM Re: String help [Re: Allen]
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
How can you reverse $string1

Edited by Allen (2014-06-04 12:51 AM)

Top
#208986 - 2014-06-03 09:01 PM Re: String help [Re: dataspike]
Allen Moderator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4314
Loc: USA
StrReverse -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=197088

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1

Top
#208987 - 2014-06-03 09:06 PM Re: String help [Re: Allen]
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
Thanks!
Top
#208988 - 2014-06-03 09:17 PM Re: String help [Re: dataspike]
Allen Moderator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4314
Loc: USA
\:\) NP
Top
#208989 - 2014-06-03 11:38 PM Re: String help [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22298
Loc: OK
what on earth is going on?
_________________________
!

download KiXnet

Top
#208990 - 2014-06-03 11:42 PM Re: String help [Re: Lonkero]
dataspike Offline
Getting the hang of it

Registered: 2005-03-09
Posts: 89
Loc: San Diego, CA
 Originally Posted By: Lonkero
what on earth is going on?
Nothing, move along.

Top
#208991 - 2014-06-04 12:43 AM Re: String help [Re: dataspike]
Allen Moderator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4314
Loc: USA
For the future, plz don't delete your posts. Not only does it break the continuity of the thread, but there are sometimes valuable lessons for others in your posts.


Edit, good lord, just noticed the first question is blanked out too... Not cool.

I will edit his posts and try put his questions back to together.


Edited by Allen (2014-06-04 12:52 AM)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
4 registered (Jochen, AndreLuiz, Flavien, Arend_) and 206 anonymous users online.
Newest Members
Sjaak, Biybucket, Markus1961, Ian231, kixnewbie12
17480 Registered Users

Generated in 0.073 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org