3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function substr_count_array( $haystack, $needle ) { $count = 0; foreach ($needle as $substring) { $count += substr_count( $haystack, $substring); } return $count; } $str = 'The fox jumped over the table and ate a frog'; $search = 'fox ate apple'; $words = explode(' ', $search); $result = substr_count_array($str, $words); if(($result / $words) * 100 > 50) { echo 'Related to your query (Total words: '.$words.', Words found: '.$result.')'; } else { echo 'Could not find anything related'; }
Output for 7.0.0 - 7.1.10
Fatal error: Uncaught Error: Unsupported operand types in /in/F5lVK:21 Stack trace: #0 {main} thrown in /in/F5lVK on line 21
Process exited with code 255.
Output for 4.3.2 - 5.6.28
Fatal error: Unsupported operand types in /in/F5lVK on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Unsupported operand types in /in/F5lVK on line 21