Skip to content
Advertisement

Modify empty keys in associative array in php

i have a really long form in wordpress that it filled out by the user and then submitted to a thirdparty crm via API.

The thing is if user doesn’t fill a field, these field will be false or empty and remote_post will fail.

I tried to add a custom value to empty fields with a foreach but they are in associative array and i dont know how to modify it.

This is my code so far (i changed values but is the same structure):

JavaScript

];

JavaScript

Advertisement

Answer

You can use recursion

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement