title: WordPress: Store data from input fields to database and than retrieve it
body: <p>I have input fields with names like: <strong>child<a href="http://jsfiddle.net/alexchizhov/LC2K6/" rel="nofollow noreferrer">1</a></strong>, <strong>child[2]</strong>, <strong>child[3]</strong> and so on. A user can add as many fields as he wants, its handled with jquery and dynamically ads an input field with [n] in the end of the name.</p>
  <p>Now I need to store this data to database in WordPress plugin I work on. And later retrieve this data to display it on the website, and of cause add those field out fields in admin page, where user edits data.</p>
  <p>I know how to store one field for example <strong>child</strong> to the database in WordPress, it would be something like that:</p>
  <pre><code>&lt;?php $child = get_post_meta( $post-&gt;ID, 'child', true ); ?&gt;
  
  &lt;?php
  function save_child_data( $post_id ) {
  
    // Check if exists
    if(! isset($_POST['child'])){return;}
  
    // Sanitize
    $child_data = sanitize_text_field( $_POST['child'] );
  
    // Store data
    update_post_meta( $post_id, 'child', $child_data);
  
  }
  add_action( 'save_post', 'save_child_data' );
  ?&gt;
  
  &lt;!-- Field in admin --&gt;
  &lt;input type=&quot;text&quot; name=&quot;child&quot; id=&quot;child&quot; value=&quot;&lt;?php echo esc_attr($child); ?&gt;&quot;&gt;
  
  &lt;!-- Front office --&gt;
  &lt;div&gt;Child: &lt;?php echo get_post_meta( $post-&gt;ID, 'child', true ); ?&gt;&lt;/div&gt;
  </code></pre>
  <p>So my question is how do I handle this array like <strong>child[n]</strong>?</p>
  <p>Or another question maybe it is better to just use <strong>child1</strong>, <strong>child2</strong>, <strong>child3</strong> and handle it as regular input fields?</p>
  <p><strong>So you understand what I mean by dynamically added block here is a jsfiddle link:</strong> <a href="http://jsfiddle.net/alexchizhov/LC2K6/" rel="nofollow noreferrer">http://jsfiddle.net/alexchizhov/LC2K6/</a></p>