title: PHP unserialize serialized data
body: <p>I have a problem with unserializing serialized data.</p>
  
  <p>The data is serialized and saved in the database.</p>
  
  <p>This data contains a uploaded .csv url that I want to give back to fgetcsv.</p>
  
  <p>fgetcsv expects a array and now a string is given, so I need to unserialize the data but this gives me errors.</p>
  
  <p>I found this online <a href="http://davidwalsh.name/php-serialize-unserialize-issues" rel="nofollow">http://davidwalsh.name/php-serialize-unserialize-issues</a> but this doesn't seem to work. So I hope somebody can tell me where I go wrong:</p>
  
  <p>Here is the error: </p>
  
  <pre><code>Notice: unserialize() [function.unserialize]: Error at offset 0 of 1 bytes in /xxx/public_html/multi-csv-upload.php on line 163
  </code></pre>
  
  <p>I found that this means that there are certain characters in the serialized data that makes the file corrupt after unserialization <code>(",',:,;)</code></p>
  
  <p>Line 163: </p>
  
  <pre><code>jj_readcsv(unserialize ($value[0]),true);` // this reads the url of the uploaded csv and tries to open it.
  </code></pre>
  
  <p>Here is the code that makes the data serialized:</p>
  
  <pre><code>update_post_meta($post_id, 'mcu_csv', serialize($mcu_csv));
  </code></pre>
  
  <p>This is WordPress</p>
  
  <p>Here is the output of:</p>
  
  <pre><code>echo '&lt;pre&gt;';
  print_r(unserialize($value));
  echo '&lt;/pre&gt;';
  </code></pre>
  
  <p><code>Array
  (
      [0] =&gt; http://www.domain.country/xxx/uploads/2014/09/test5.csv
  )</code></p>
  
  <p>The way I see it there shouldn't be anything wrong here.</p>
  
  <p>Anybody some idea's how I can unserialize this so I can use it?
  Here is what I did sofar...</p>
  
  <pre><code>public function render_meta_box_content($post)
  {
  
      // Add an nonce field so we can check for it later.
      wp_nonce_field('mcu_inner_custom_box', 'mcu_inner_custom_box_nonce');
  
      // Use get_post_meta to retrieve an existing value from the database.
      $value = get_post_meta($post-&gt;ID, 'mcu_images', true);
  
      echo '&lt;pre&gt;';
          print_r(unserialize($value));
      echo '&lt;/pre&gt;';
  
      ob_start();
      jj_readcsv(unserialize ($value[0]),true);
      $link = ob_get_contents();
      ob_end_clean();
      $editor_id = 'my_uploaded_csv';
  
      wp_editor( $link, $editor_id );
  
  
  
  
      $metabox_content = '&lt;div id="mcu_images"&gt;&lt;/div&gt;&lt;input type="button" onClick="addRow()" value="Voeg CSV toe" class="button" /&gt;';
      echo $metabox_content;
  
      $images = unserialize($value);
  
      $script = "&lt;script&gt;
          itemsCount= 0;";
      if (!empty($images))
      {
          foreach ($images as $image)
          {
              $script.="addRow('{$image}');";
          }
      }
      $script .="&lt;/script&gt;";
      echo $script;
  }
  
  function enqueue_scripts($hook)
  {
      if ('post.php' != $hook &amp;&amp; 'post-edit.php' != $hook &amp;&amp; 'post-new.php' != $hook)
          return;
      wp_enqueue_script('mcu_script', plugin_dir_url(__FILE__) . 'mcu_script.js', array('jquery'));
  }
  </code></pre>