The vertical pipe character (|
) has a special meaning when used inside a regular expression. It is used for specifying alternatives in a regular expression. You need to properly escape it if you want to match the literal |
character:
if(preg_match("/\|/",$value)){
# code ...
}