次のpythonに相当するものは何ですか:
if (strpos($elem,"text") !== false) {
// do_something;
}
次のpythonに相当するものは何ですか:
if (strpos($elem,"text") !== false) {
// do_something;
}
pos = haystack.find(needle)
pos = haystack.find(needle, offset)
pos = haystack.index(needle)
pos = haystack.index(needle, offset)
部分文字列が文字列内にあるかどうかを単純にテストするには、次を使用します。
needle in haystack
これは、次の PHP と同等です。
strpos(haystack, needle) !== FALSE
if elem.find("text") != -1:
do_something