<?php
$dwellingInfo = [
["AAA", "Chimney with red bricks"],
["BBB", "Two wide windows in the main floor"],
["CCC", "Roof tiles renewed in 2015"]
];
$haystack = implode(
',',
array_column($dwellingInfo, 1)
);
$dwellingAttributes = [
["0001", 'Chimney', '/\b(?:Chimney with|Big stove)\b/i'],
["0002", 'Garden', '/\bgarden\b/i'],
["0003", 'Roof tiles', '/\bRoof tiles\b/i'],
["0004", 'Windows', '/\bwindows?\b/i'],
["0005", 'Garage', '/\b(?:garage|car port|under cover area)\b/i']
];
foreach ($dwellingAttributes as [$id, $term, $pattern]) {
printf(
"%s - %s - %s\n",
$id,
$term,
preg_match($pattern, $haystack)
? 'available'
: 'unavailable'
);
}
- Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- 0001 - Chimney - available
0002 - Garden - unavailable
0003 - Roof tiles - available
0004 - Windows - available
0005 - Garage - unavailable
preferences:
121.13 ms | 402 KiB | 121 Q