【发布时间】:2020-10-22 04:35:33
【问题描述】:
例如我的输入字符串是
$edition = Vol.123 or Edition 1920 or Volume 951 or Release A20 or Volume204 or Edition967
如何检查字符串中的单词是否与数组中的任何单词匹配。
$editionFormats = ['Vol','Volume','Edition','Release'];
基本上我需要检查输入是否有Vol或Volume或Edition或Release。
谁能提供一种检查模式的方法?
我尝试使用str_pos()、preg_grep()、preg_match()、split()、str_split() 我的想法是在第一次出现句号或空格或数字后拆分字符串,
但是没找到。
【问题讨论】: