3

I using array recursive to find leaf. My function is working, I easy printing value from leaf. Now i trying get value out of function, i need use this for another function. This is my code.

$nazwa;     
function testArrayItem($item, $key)
    {
        if($key== "values")
        {
            $nazwa=$item;
        }
    }

    array_walk_recursive($des1['values']['0'], 'testArrayItem');
echo $nazwa;

My varible "$nazwa" is empty how i can get value from my function? Thx for help

1 Answer 1

2

I just had the same problem as you did. But defining the variable as global is not correct in any case. Look at my answer on this thread.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.