Skip to content
Advertisement

PHP recursive function returning null array

I have a huge array in which keys are also not constant in most of the cases, but there are 3 keys that always constant (#name,#default_value,#value) and #default_value and #value is different i want to get these kind of sub arrays in 1 simple array , for this purpose i am using recursion in whole array and checking out if these 3 keys are present there i can print these values inside recursion easily but I am not able to get those values in return. So that i can precess them further.

JavaScript

If you run this code it will give you $arr_get > array (size=0), there i need all three values

Advertisement

Answer

If I understand correctly, you need to pass fields as a reference in order to change it:

function get_updatedvalues($form, &$fields) {

To do that, however, you’ll need to change your initial call so that you have a variable to pass as the reference:

JavaScript

Running this I get:

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