title: PHP Restore an Array from a String
body: <p>I have an array which is very complicated to generate.</p>
  
  <p>Hence, would like to generate it once and then store as a string in a database.</p>
  
  <p>Then, whenever it is needed, it can be simply retrieved from the DB as a string and declared as an array. Is there an easy way to do such a thing on PHP <strong>without using the eval() function</strong>.</p>
  
  <p>So the string in the db might be something like</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              ['none'] =&gt; Array
                  (
                      ['none'] =&gt; Array
                          (
                              ['Page'] =&gt; Array
                                  (
                                      [0] =&gt; 1
                                      [1] =&gt; 2
                                      [2] =&gt; 3
                                  )
  
                          )
  
                  )
  
          )
  
      [1] =&gt; Array
          (
              ['Volume 1'] =&gt; Array
                  (
                      [] =&gt; Array
                          (
                              ['Page'] =&gt; Array
                                  (
                                      [27] =&gt; 18
                                      [28] =&gt; 19
                                      [29] =&gt; 20
                                  )
  
                          )
  
                  )
  
              ['Volume 2'] =&gt; Array
                  (
                      [] =&gt; Array
                          (
                              ['Page'] =&gt; Array
                                  (
                                      [0] =&gt; 1
                                      [1] =&gt; 2
                                      [2] =&gt; 3
                                      [3] =&gt; 4
                                      [4] =&gt; 5
                                      [5] =&gt; 6
                                  )
  
                          )
  
                  )
  
          )
  
  )
  </code></pre>