2
我公司目前有以下strpos/stripos函数(都尝试,不改变结果),从论坛帖子用于标记某些针。strpos/stripos函数(严格的比较)未能
if (stripos($row->message, (string)$commit) !== false) {
// Do stuff
}
的东西大多是工作正常,然而,在少数情况下,当草垛($按行>消息)包含针($提交)(使用造型,因为$承诺可以是int)strpos/stripos函数的返回false 。
例如:
$test = stripos($row->message, (string)$commit);
非工作情况下的一个例子是:
// (string)$commit
string(7) "818df50"
// $row->message
string(321) "Intro. Crashes as soon as the main menu is shown. Graphics are horribly broken, no fixes have been found as of yet. [attachment=194] Build Used: Pull Request #3333 (0.0.3-5929) -> RPCS3-v0.0.3-2017-08-27-818f50b Side note: States it can display at 1080p, yet it is boxed in 1080p. However, it is fine in 720p."
// $test (strpos/stripos)
bool(false)
工作情况的一个例子是:
// (string)$commit
string(7) "2570911"
// $row->message
string(219) "RPCS3 v0.0.3-3-2570911 Alpha The game doesn't even show its graphics window. [quote] ·F 0:00:34.138812 {PPU[0x1000000] Thread (main_thread) [0x0087c094]} MEM: Access violation writing location 0xcffff2d0 [/quote]" int(15) [2570911]
// $test (strpos/stripos)
int(15) [2570911]
我不知道我是否错过了一些非常明显的东西,我检查了几次,方法似乎正确。
注:我知道有几十种方法可以做到这一点,但在这种特定情况下,我需要这些字符串比较。
在此先感谢。
哦,哈哈,我需要更多的睡眠。看了几次,并没有注意到这样一个愚蠢的错误。谢谢! – Ani