2015-06-03 93 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, '|')) { ... }