In PHP, how do I filter strings with SPL?

ceo, leadership, management
This is a simple example of filtering strings using SPL in PHP.
<?php // Example usage of SPL to filter strings $strings = ["CEO", "CFO", "CTO", "COO", "Manager", "Director"]; // Create a filter to only get titles that start with 'C' $iterator = new ArrayIterator($strings); $filter = new CallbackFilterIterator($iterator, function($item) { return strpos($item, 'C') === 0; // Filter condition: starts with 'C' }); // Collect filtered results $filteredStrings = iterator_to_array($filter); // Output filtered strings foreach ($filteredStrings as $string) { echo $string . "<br>"; } ?>

ceo leadership management