<?php
function label_patterns(array $patterns): array {
    $out = [];
    foreach ($patterns as $key => $pattern) {
        $out[] = $key . '=' . $pattern;
    }
    return $out;
}

foreach (label_patterns(['device' => '/Device/', 'barcode' => '/Barcode/']) as $line) {
    echo $line, PHP_EOL;
}

foreach (label_patterns(['zero', 3 => 'three']) as $line) {
    echo $line, PHP_EOL;
}
