& lt;? php
$ bookshelf = array (
array (
array (
'author' = & gt; 'L. Thick',
'title' = & gt; 'War and Feast',
'year' = & gt; 2005,
),
array (
'author' = & gt; 'N. Gogol-Mogol ',
'title' = & gt; 'Dead ears',
'year' = & gt; 2005,
),
),
array (
array (
'author' = & gt; 'G. Wells',
'title' = & gt; 'Burden Machine'
'year' = & gt; 2009,
),
array (
'author' = & gt; 'NS. Derrows',
'title' = & gt; 'Narzan',
'year' = & gt; 1994,
),
),
);
$ bookshelf [] = 'SuperPuper';
object2file ($ bookshelf, 'array.txt');
Answer 1, authority 100%
$ filename = 'array.txt';
// Record.
$ data = serialize ($ bookshelf); // PHP format of the stored value.
// $ data = json_encode ($ bookshelf); // JSON format of the stored value.
file_put_contents ($ filename, $ data);
// Reading.
$ data = file_get_contents ($ filename);
// $ bookshelf = json_decode ($ data, TRUE); // If not TRUE then get an object, not an array.
$ bookshelf = unserialize ($ data);