0

How to save a list in file as an array.

Eg. file contains apple, mango, banana this has to be stored as an array like $fruits = array("apple","mango","banana");

9th Aug 2019, 5:22 AM
Arvind Tarpasa
Arvind Tarpasa - avatar
1 ответ
0
I don't know exactly about PHP, but in Python you would do: f = open("somefile.txt","r") file_contents = f.read() fruits = file_contents.split(",") The "split" method splits the string up at the given character and returns an array. You can look up what the PHP equivalent is.
9th Aug 2019, 5:32 AM
Paul Grasser
Paul Grasser - avatar