[DGD] Explode() question
Shevek
shevek at btinternet.com
Tue Jan 1 01:33:22 CET 2002
More of a question of am I using it right than is something wrong.
Is this expected behaviour from explode?
Read a file into some string str, file contains this line.
string1:string2:string3
Now explode(str,":") into an array arrstr.
Here is the problem, the final element of arrstr is now string3 + some
unknown control character, so trying to check a string to see if it's a
member of arrstr will fail if the string=string3.
Solutions are trivial of course.
Adding another seperator to the file, but here this gives an array of 4
strings with the last string being the unknown control char.
Or use this to fix the last element:
i=sizeof(arrstr)-1;
arrstr[i]=arrstr[i][0..strlen(arrstr[i])-2];
Which gives the correct result.
Is this problem there because of the read_file() command reading in a
control char at the end of the file? Or is it something to do with
explode() itself? Or, and more likely, am I just using it wrong?
I checked this out using both my desktop editor and the DGD editor to
produce the input file.
Cheers,
Shevek
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list