I am currently trying to use PHP to track the number of “likes” on the pages of my site. What I would like to do is put all the information in one array, not a separate file for each page, each of which contains one integer. What I was trying to do was set up a file (name it data.txt) that contains this array.
$array = array(
"Page1" => 10,
"Page2" => 3,
);
For example, above, page 1 has 10, while page2 - 3.
This is the real meat of the matter: . How can I write the above array to a text file and then read it later? Most of the approaches I tried end up simply reading a string that is not what I'm looking for (I want to be able to easily access the number of likes directly to the array).
Here var_dumpfor everyone who was interested:
array(2) { ["Page1"]=> int(10) ["Page2"]=> int(3) }
Maybe there is a way to parse this array?
source
share