Peter Van Eeckhoutte (corelan)
16 years ago
Hello,
I have a string that looks like this
mystring="value1=1 value2=a value3=cd value4=jj";
I would like to be able to put this in individual arrays (each of 2 elements) that can be walked through via a "foreach" iteration
My first idea was to use 2 split functions
array1=split(mystring," ");
then for each array1 member, split it again :
foreach arraymember (array1)
{
arrayentry=split(arraymember,"=");
foreach field (arrayentry)
{
display(string("item :",field,"\n");
}
}
but this does not seem to work... I get the entire string every time, so it looks like the split function is not doing anything
(however, when I do a split without parameters on a large chunck of text, trying to split this text into lines, it works fine.. but as soon as I want to use a separator, it stops working)
what is wrong here ?
thanks
____________________________________________________
Peter Van Eeckhoutte
***@telenet.be - ***@corelan.be
____________________________________________________
My Blog : http://www.corelan.be:8800 (IPv4 and IPv6)
My Tools : http://freetools.corelan.be
RIPE Handle PVE50-RIPE
a.k.a. c0d3r on various forums
____________________________________________________
This transmission is intended only for use by the intended recipient(s). If you are not an intended recipient you should not read, disclose, copy, circulate or in any other way use the information contained in this transmission. The information contained in this transmission may be confidential and/or privileged. If you have received this transmission in error, please notify the sender immediately and delete this transmission including any attachments.
I have a string that looks like this
mystring="value1=1 value2=a value3=cd value4=jj";
I would like to be able to put this in individual arrays (each of 2 elements) that can be walked through via a "foreach" iteration
My first idea was to use 2 split functions
array1=split(mystring," ");
then for each array1 member, split it again :
foreach arraymember (array1)
{
arrayentry=split(arraymember,"=");
foreach field (arrayentry)
{
display(string("item :",field,"\n");
}
}
but this does not seem to work... I get the entire string every time, so it looks like the split function is not doing anything
(however, when I do a split without parameters on a large chunck of text, trying to split this text into lines, it works fine.. but as soon as I want to use a separator, it stops working)
what is wrong here ?
thanks
____________________________________________________
Peter Van Eeckhoutte
***@telenet.be - ***@corelan.be
____________________________________________________
My Blog : http://www.corelan.be:8800 (IPv4 and IPv6)
My Tools : http://freetools.corelan.be
RIPE Handle PVE50-RIPE
a.k.a. c0d3r on various forums
____________________________________________________
This transmission is intended only for use by the intended recipient(s). If you are not an intended recipient you should not read, disclose, copy, circulate or in any other way use the information contained in this transmission. The information contained in this transmission may be confidential and/or privileged. If you have received this transmission in error, please notify the sender immediately and delete this transmission including any attachments.