Page 1 of 1

convert string (from text file) to array

Posted: Thu Oct 09, 2003 6:36 am
by raymedia
hi guys..wassup. my question is pretty basic but important 4 me.

i have a text file let say "a.txt" whic contains:-
*****************************************

їїa,b,c,d,ї1,2,3,4,5],їa,b,c,d,ї1,2,3,4,5]]]

*****************************************
the content is a 2 dimentional array..but of course i have to read it as a string. my question is can i turn this back as an array..

this is my code:
їcode]
$content = settype(file("a.txt"),"array");
ї/code]
but it seems not right..i tried to look everywhere on internet but no luck. if anyone can help me..it'll be great. thank guys

Posted: Thu Oct 09, 2003 8:47 am
by scorphus
You could implement a recursive function to walk through your string and 'mount' the multi-array.

Posted: Thu Oct 09, 2003 8:52 am
by scorphus
But if you have control over the way the string is sent to file, take a look to this post (by Jam). It is about serialize and base64_encode. I think it may help you.

Cheers,
Scorphus.

Posted: Thu Oct 09, 2003 9:22 am
by raymedia
thanx scorpus..that was what i was looking for..i don't care if the text file is readable..as long i can use it back as an array. thankx again bro.