[英]How to Check If a String Contains a Specific Word with uppercase and lowercase in PHP
i want to check the string contains "SDN", whether it is uppercase or lowercase such as "sdn", "Sdn", "sDN and so on, how can I get all that?我想检查字符串是否包含“SDN”,是大写还是小写,例如“sdn”、“Sdn”、“sDN”等,我怎样才能得到所有这些?
I using strpos($company_name, 'SDN') now and only can get the "SDN".我现在使用 strpos($company_name, 'SDN') 只能得到“SDN”。
try converting both to the same case:尝试将两者转换为相同的情况:
strpos(strtoupper($company_name), 'SDN');
You could also use preg_match
你也可以使用
preg_match
preg_match('/SDN/i', $company_name);
https://www.php.net/manual/en/function.preg-match.php https://www.php.net/manual/en/function.preg-match.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.