2

多次元配列をクリーンアップするために書いている関数の最終ステップに苦労しています。関数が配列 (およびサブ配列) をループしてから、クリーンな配列を返すようにします。

きれいなデータを出力するために使用できますarray_walk_recursiveが、入力と同じ構造の配列としてデータを返すのに苦労しています。誰でも助けることができますか?どんな助けでも大歓迎です....

これが私のコードです:

function process_data($input){
    function clean_up_data($item, $key)
    {
        echo strip_tags($item) . ' '; // This works and outputs all the cleaned data
        $key = strip_tags($item);     // How do I now output as a new array??
        return strip_tags($item);
    }
    array_walk_recursive($input, 'clean_up_data');
}

$array = process_data($array);  // This would be the ideal usage
print_r($array);  // Currently this outputs nothing
4

2 に答える 2