Page 1 of 1 1
Topic Options
#58697 - 2001-08-30 10:54 AM Reading parts of a line
Anonymous
Unregistered


How can kixtart read different parts of one line?
For example, I have this lines:

a1a;20342;anna ardts
h3da;15006;kim van arendonk

Then the results of the first line must be:

code:

$class=a1a
$nr=15006
$name=anna ardts


From the second line the results must be:

code:

$class=h3da
$nr=20342
$name=kim van arendonk

Anyone any idea?

Top
#58698 - 2001-08-30 10:58 AM Re: Reading parts of a line
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
first, I don't get how you get from one line two lines... kind off mixed mode...

well if you are trying to read only one line, easiest is to use split.
it's kix2001 function, so if you need it in 3.63 you will need some scripting. it means use of instr() and substr() functions.

_________________________
!

download KiXnet

Top
#58699 - 2001-08-30 11:58 AM Re: Reading parts of a line
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Something like this:

code:

$line="a1a;20342;anna ardts"

$class=substr($line,1,instr($line,";")-1)
$rest=substr($line,instr($line,";")+1,len($line))

$nr=substr($rest,1,instr($rest,";")-1)
$name=substr($rest,instr($rest,";")+1,len($rest))

? $class
? $nr
? $name


HTH

_________________________
The Code is out there

Top
#58700 - 2001-08-30 03:05 PM Re: Reading parts of a line
Anonymous
Unregistered


Nice script, but after running the script I get the error "Script error : invalid method/function call: missing comma ! SPLIT ("$line", ";", 3)
Top
#58701 - 2001-08-30 03:25 PM Re: Reading parts of a line
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
Hi Sander,

If you're using Kix2001 this should work:

code:

$line="a1a;20342;anna ardts"

$array=SPLIT ("$line",";")

$class=$array[0]
$nr=$array[1]
$name=$array[2]

? $class ? $nr ? $name


notice that I haven't used the number of array fields. I think it doesn't work correctly. (see the beta board for more info)

_________________________
The Code is out there

Top
#58702 - 2001-08-31 09:42 AM Re: Reading parts of a line
Anonymous
Unregistered


Thanks Drillsergeant, this works well!
Nice version that kix2001.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 756 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.054 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

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