Sunday 15 January 2012

How can i read a text file which contains a proper array in php? -


I used it to write an array in a text file:

  $ fp = Fopen ('file.txt', 'w'); FILIT ($ fp, print_r ($ new trusting, true)); Fclose ($ FP);  

Now I want to read it back in PHP like I would have read a normal array? How do I do this? I am quite new to this and currently at a certain time to get something related to this fix, pls help

will be a valid PHP code, then you can include and function better than print_r () , but I would suggest using JSON / I will work similarly to JSON but not portable.

Type:

  file_put_contents ('file.txt', json_encode ($ newStrings));  

Read:

  $ newStrings = json_decode (file_get_contents ('file.txt') is true);  

No comments:

Post a Comment