admin管理员组

文章数量:1406918

With a form I am saving the data to WordPress options, it's a big multidimensional array. The problem that I am facing is sometimes it misses a value in the array. I am not sure how to debug that as it works 80% of time. Can this be related as I am saving it as an array?

With a form I am saving the data to WordPress options, it's a big multidimensional array. The problem that I am facing is sometimes it misses a value in the array. I am not sure how to debug that as it works 80% of time. Can this be related as I am saving it as an array?

Share Improve this question edited Nov 25, 2019 at 12:41 butlerblog 5,1213 gold badges28 silver badges44 bronze badges asked Nov 25, 2019 at 7:49 user145078user145078 2
  • 1 You're not just randomly losing values in an array just because you're saving an array. You're losing data because there's a mistake in your code. It doesn't matter what format you choose to save in if your code has an error. This is not an inherent problem with arrays. – Jacob Peattie Commented Nov 25, 2019 at 11:34
  • @JacobPeattie Yeah it was an error in the code. – user145078 Commented Nov 25, 2019 at 11:56
Add a comment  | 

1 Answer 1

Reset to default 0

It depends, if you use the data, only as a whole. Lets say for configuration settings or something, then I would say, it's not a problem. But if you are doing queries on the data, like searching or fetching only 1 or 2 fields from that array.. you should use other solutions.

If you are missing some values from your array, are you sure these values are submitted from your form? (Are the fields not "disabled", or are these fields unchecked checkboxes?)

本文标签: Is saving data to WordPress options as array bad thing to do