3v4l.org

run code in 300+ PHP versions simultaneously
<?php function percentageSubStrings(array $inputs, array $needles): Generator { foreach($inputs as $input) yield [$input => ((count($words = explode(' ', $input)) - count(array_diff($words, array_filter($needles, fn($x) => in_array($x, $words))))) / count($needles)) * 100]; } var_dump(iterator_to_array(percentageSubStrings(['Some short text', 'Some much longer text'], ['Some', 'text', 'longer', 'much'])));

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
167 ms | 2038 KiB | 15 Q