convert string (from text file) to array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
raymedia
Forum Commoner
Posts: 27
Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia

convert string (from text file) to array

Post 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
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

You could implement a recursive function to walk through your string and 'mount' the multi-array.
Last edited by scorphus on Thu Oct 09, 2003 8:53 am, edited 1 time in total.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post 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.
User avatar
raymedia
Forum Commoner
Posts: 27
Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia

Post 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.
Post Reply