$resultArray = [];
$regionName = "";
foreach($queryResult as $currentItem)
{
if($currentItem["regionName"] != $regionName)
{
$resultArray[$currentItem["regionName"]] = [];
array_push($resultArray[$currentItem["regionName"]], $currentItem["cityName"]);
$regionName = $currentItem["regionName"];
}
else
{
array_push($resultArray[$currentItem["regionName"]], $currentItem["cityName"]);
}
}
var testStr = ['some text (part1)',
'even some text (part1)',
'some text / ... (part1) (part2)',
'(part1)'].join('\n');
var rg = new RegExp(/(.*?)(?:\(|\/)(?:.*?)\n/, 'gim');
while(item = rg.exec(testStr))
{
console.log(item[1]);
};
$testStr = 'some text (part1)
even some text (part1)
some text / ... (part1) (part2)
(part1)
';
preg_match_all("#(.*?)(?:\(|/)(?:.*?)\n#is", $testStr, $matches);
print_r($matches);