Recursive loop for multidimenional arrays?

后端 未结 2 1043
说谎
说谎 2021-01-07 03:12

I basically want to use str_replace all values of a multidimenional array. I cant seem to work out how I would do this for multidimenional arrays. I get a little stuck when

2条回答
  •  执念已碎
    2021-01-07 04:04

    ...What's wrong with array_walk_recursive?

     'apple', 'b' => 'banana');
    $fruits = array('sweet' => $sweet, 'sour' => 'lemon');
    
    function test_print($item, $key)
    {
        echo "$key holds $item\n";
    }
    
    array_walk_recursive($fruits, 'test_print');
    ?>
    

提交回复
热议问题