Ok posting this query after going through many similar issues but they took into consideration only numeric values. So my issue is:
I have 2 arrays -
$a = ["XYZ1250H100",
"XYZ1280H130",
"XYZ1250H150",
"XYZ3300H200",
"XYZ3350H200",
"XYZ33350H280Ada08",
"XYZ33450H300Ada08",
"XYZ33508H406Ada08"];
and
$b = ["XYZ0L200H150A4c00",
"350L610H457Ada08",
"XYZ33762H610Ada08",
"350L914H610Ada08",
"3700L250H200A410b",
"XYZ33457H305Ada08",
"XYZ4550H100MMQOJ",
"XYZ4580H130Ada08",
"XYZ4550H150A69b5",
"3101L280H356A8b83",
"XYZ4550H1501FC5Z",
"3116L150H15074QFR",
"XYZ1250H200A21ac",
"3101L750H500A8b83",
"350L356H279Ada08",
"XYZ1250H200A3f1c",
"3700L153H102A8d96",
"XYZ4550H150Ada08",
"XYZ4580H130A69b5",
"350L1830H610Ada08",
"3700L153H102A4c00",
"XYZ4550H150STD9J",
"3800L200H1505CZJI",
"XYZ4550H100A69b5",
"XYZ331370H450Ada08"
];
I need to see if values of array $a are there in array $b, I tried to use array_diff() and array_intersect() but that didn't solve the purpose. What I want is if the 2 arrays are matched then it should return either true or false. So for example if we consider value in $a -> "XYZ1280H130" and value in $b -> "XYZ1280H130A69b5" then it should be considered as a matched value (coz former is a sub-string of latter value) and true should be return and same for all similar values.
I tried something like this but it gives back all values of array $b everytime:
$result = array_filter($a, function($item) use($b) {
foreach($b as $substring)
if(strpos($item, $substring) !== FALSE) return TRUE;
return FALSE;
});
Please let me know if I missed something. Thanks in advance.