Title: saving custom fields values as an array
Last modified: September 1, 2016

---

# saving custom fields values as an array

 *  Resolved [Vikas Khunteta](https://wordpress.org/support/users/vikas_khunteta/)
 * (@vikas_khunteta)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/saving-custom-fields-values-as-an-array/)
 * I have been using Meta Box Plugin version 4.8.7, I really like this tiny plugin
   compared to ACF.
 * I need help to achieve something very complex scenario. I created one meta box
   and populated it with some fields using loop, there are 5 fields into each section.
   One field is URL, another is hidden field & the rest three are text fields and**
   I want to save these three text fields with hidden field values as an array**.
 * In my code `name` attribute of text fields looks like
 *     ```
       hidden field => name="arr[61][0]"
       field 1 => name="arr[61][1]"
       field 2 => name="arr[61][2]"
       field 3 => name="arr[61][3]"
       ```
   
 * Here 61 is the ID of some post.
 * There will be some more identical hidden fields with different `name` attributes
   and values. All these data will become one large array. I have pasting one single
   section result to explain it more.
 *     ```
       a:15:{i:61;a:4:{i:0;a:4:{s:5:"value";i:0;s:5:"start";i:0;s:7:"enabled";i:1;s:3:"end";i:15;}i:1;a:4:{s:5:"value";i:10;s:5:"start";i:15;s:3:"end";i:45;s:7:"enabled";i:1;}i:2;a:4:{s:5:"value";i:25;s:5:"start";i:45;s:3:"end";i:95;s:7:"enabled";i:1;}i:3;a:4:{s:5:"value";i:25;s:5:"start";i:95;s:3:"end";i:100;s:7:"enabled";i:1;}}
       ...
       ...
       ...
       }
       ```
   
 * As you can see there are 15 arrays and that post id as first key which contains
   another 4 arrays. Other than `value`, `start, end, enabled` will be hidden.
 * Other than saving all the data like above, I want to populate the all visible
   fields and hidden fields with the data which will be saved into array. That large
   array will be saved into single row of `wp_postmeta` table.
 * Is this possible to achieve?
 * Let me know if I am failed to explain or if you have any question or doubt.
 * [https://wordpress.org/plugins/meta-box/](https://wordpress.org/plugins/meta-box/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [Vikas Khunteta](https://wordpress.org/support/users/vikas_khunteta/)
 * (@vikas_khunteta)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/saving-custom-fields-values-as-an-array/#post-7503410)
 * I managed to save values into database in array format using `save_post` Action
   Hook but now how I can pre filled the fields meta value with the value saved 
   into database. The `std` key is not working after first post update. The `std`
   work only first time before the post saved with the custom fields.
 * I went through all the docs publish by you, I found one filter at [rwmb_field_meta](https://metabox.io/docs/filters/#section-rwmb_field_meta)
   but I didn’t find any filter in the plugin code with this name. So I am doubt
   if its exists or not.
 * If its exists than how I can use this filter to set default value.
 *  Plugin Author [Anh Tran](https://wordpress.org/support/users/rilwis/)
 * (@rilwis)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/saving-custom-fields-values-as-an-array/#post-7503501)
 * Hi,
 * The only solution we have for now is using [the Group extension](https://metabox.io/plugins/meta-box-group/).
   It allows us to create an array of fields and saves values in a single entry 
   in the database (as an array).
 *  [navidsafavi](https://wordpress.org/support/users/navidsafavi/)
 * (@navidsafavi)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/saving-custom-fields-values-as-an-array/#post-8342203)
 * i want save image advance in one key like array. save all ID image in one key
 * could you help me?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘saving custom fields values as an array’ is closed to new replies.

 * ![](https://ps.w.org/meta-box/assets/icon-128x128.png?rev=1100915)
 * [Meta Box](https://wordpress.org/plugins/meta-box/)
 * [Support Threads](https://wordpress.org/support/plugin/meta-box/)
 * [Active Topics](https://wordpress.org/support/plugin/meta-box/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/meta-box/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/meta-box/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [navidsafavi](https://wordpress.org/support/users/navidsafavi/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/saving-custom-fields-values-as-an-array/#post-8342203)
 * Status: resolved