How do I pass the value from a foreach loop to an add_filter function? [closed]

foreach ( $myarray as $key => $value ) {
     add_filter( "plugin_filter_$key", function () use ( $value ) { return $value; } );
}

Check out the use keyword for closures.