How can the PHP function array_filter be used to manipulate database values retrieved using get_option() in WordPress?

When retrieving database values using get_option() in WordPress, it may be necessary to filter out certain values before using them in your code. This can be achieved using the PHP function array_filter, which allows you to apply a callback function to each element of an array and only keep the elements that meet a certain condition. By using array_filter in combination with get_option(), you can manipulate the retrieved values as needed before using them in your WordPress site.

// Retrieve database values using get_option()
$options = get_option('my_option');

// Define a callback function to filter out specific values
function filter_callback($value) {
    // Filter out values that meet a certain condition
    return $value != 'filtered_value';
}

// Use array_filter to apply the callback function to the retrieved values
$options_filtered = array_filter($options, 'filter_callback');

// Now you can use the filtered values in your code
foreach ($options_filtered as $option) {
    // Do something with each option
}