I’m not certain, but two things I think you should try:
- Loop through your
$value
variable with a foreach instead of using the built in functions.
- You’re overwriting
$value
within the loop which is destructive. Return it untouched if you want the fields saved, or wipe it clean if you want to use the data but not save any of it. Either way, outside the loop.
Hope those help.