我正在尝试进行搜索,以确保我们的每个产品标题都包含其制造商代码。我正在使用preg_match,但得到了一些奇怪的结果。
以下是我为浏览产品阵列而编写的代码片段。。。
while($row = mysql_fetch_array($result))
{
$products[ .$row[0]. ][0] = $row[0]; // Product ID
$products[ .$row[0]. ][1] = $row[1]; // MFG Part Number
$products[ .$row[0]. ][2] = $row[2]; // Product Title
$search_str = $products[ .$row[0]. ][1];
$str_to_search = $products[ .$row[0]. ][2];
if(preg_match("~" . $search_str . "~i" ,$str_to_search)){
以下是它返回的内容。。。(按数组顺序排列)
5300250, P-17(352), Cal June 17" Plastic Buoy Ring P-17(352) NO Match!
5300251, P-21 (352), Cal June 21" Plastic Buoy Ring P-21 (352) NO Match!
5708116, DS-683(12PK), Dr. Shrink Weather Tight Vents 12/Pack DS-683(12PK) NO Match!
5708117, DS-062A(12 PK), Dr. Shrink Hooded Vent 12/Pack DS-062A(12 PK) NO Match!
5802165, 2PB2 (PR), Rod Saver Paddle Bucket 2"x2 Transom Tie Down 2PB2 (PR) NO Match!PHP Warning: preg_match(): Compilation failed: nothing to repeat at offset 7 in /www/www.boatersplus.com/inventory/append-mfg-code-to-title.php on line 39
5344226, MA7170**, Mustang Survival Re-Arm Kit (For Use With md3003,md3025) MA7170** NO Match!
6503286, 4140(140D), Master Lock Padlock 1 1/2" Brass 4140(140D) NO Match!
6503287, 4150(150D), Master Lock Padlock 1 7/8" Brass 4150(150D) NO Match!
6217549, RBX-123 *NEW*, Solas Hub Kit M/m 1 1/4" RBX-123 *NEW* NO Match!
6503285, 4130(130D), Master Lock Padlock 1 1/8" Brass 4130(130D) NO Match!
6216389, 18-6773 (DROPSHIP), Sierra Trim Motor 18-6773 (DROPSHIP) NO Match!
5802166, 2PB4 (PR), Rod Saver TieDown Pbkl Svr 2"x4 2PB4 (PR) NO Match!
5802167, 2PB6 (PR), Rod Saver TieDown Ratchet Svr 2PB6 (PR) NO Match!
6217458, RBX-127 *NEW*, Solas Hub Kit Yam F350 RBX-127 *NEW* NO Match!
MM-DD80ALL(R), DD80-A-LL(R), Dana M80 Drive-rebuilt,old Style DD80-A-LL(R) NO Match!
因此,由于某种原因,这些不匹配,看起来是括号和星号不匹配。
如果能为我指明正确的方向,我们将不胜感激。
谢谢
克里斯·爱德华兹