<?php $string = 'yes or yes no or yes yes or no maybe yes or yes maybe yes or no yes maybe or yes maybe yes maybe yes maybe or'; $array = explode("\n", $string); $expected = []; //print_r($array); foreach($array as $line){ $words = substr_count($line,'yes'); if($words==2 && strpos($line, 'or') !== false ){ $expected[]= $line; } } echo implode("\n",$expected);
You have javascript disabled. You will not be able to edit any code.