#58697 - 2001-08-30 10:54 AM
Reading parts of a line
|
Anonymous
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
|
|
|
|
#58699 - 2001-08-30 11:58 AM
Re: Reading parts of a line
|
DrillSergeant
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
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
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
Anonymous
Unregistered
|
Thanks Drillsergeant, this works well! Nice version that kix2001.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 756 anonymous users online.
|
|
|