この状況で FOREACH を使用する方法
foreach($str as $key=>$row)<br /> {<br /> if(preg_match_all('/\b[Nn][Ss][Kk]-\w{5}/',$sn,$match)){<br /> $str[$key]['darfon_pn']=substr_replace($match[0][0],$row['darfon_pn'],7,2);<br /> }else{<br /> $str[$key]['darfon_pn'] = '';<br /> }<br /> }
$sn = 'NSK-34582 NSK-UUS89 NSK-89234';<br /> preg_match_all('/\b[Nn][Ss][Kk]-\w{5}/',$sn,$match);<br /> print_r($match[0]);<br /> $str = '________';<br /> foreach($match[0] as $v) {<br /> $str = substr_replace($v, $str,7,2);<br /> echo $str,PHP_EOL;<br /> }<br />