2015-06-03 91 views

回答

1

這應該做的工作。

$string = '$18,000 | new price'; 

if (strpos($string , '|') === false) { 
    // Not found. 
} 
else { 
    // Found. 
} 

http://php.net/strpos

1

圖案是錯誤的。在這種情況下不需要^。應該是 -

preg_match('/[|]/', $string); 

您可以使用storpos -

$string = '$18,000 | new price'; 
if(strpos($string, '|')) { ... }