

<?php
$haystack='Data set 1: hay2= this is a bunch of hay  hay1= Gold_Needle hay=Gold
			 Data Set 2: hay2=Silver_Needle hay=Silver';

$needle1_Begin='hay1=';
$needle2_Begin='hay2=';
			
$needle1_End='hay=Gold';
$needle2_End='hay=Silver';
	
$starts = array($needle1_Begin,$needle2_Begin);
$ends = array($needle1_End,$needle2_End);

$re = array_reduce($starts, function($res, $e) use (&$ends) {
	$res .= '(' . $e . '\h*\K(?:.(?!' . $e . '))*?(?= ' . current($ends) . '))|';
	next($ends); return $res;} );
$re = '/' . substr($re, 0, -1) . '/';

if (preg_match_all($re, $haystack, $m))
   print_r($m[0]);
?>