要素Aが配列Bの中に存在するか調べるには in_array を使う。
以下の例では、配列Bの中に要素Aが存在するので「Got elementA」が出力されます。
$arrayB = array("elementA", "NT", "Irix", "Linux");
if (in_array("elementA", $arrayB)) {
echo "Got elementA";
}
$string = ‘Hello World!’;
if(stristr($string, ‘earth’) === FALSE) {
echo ‘”earth” not found in string’;
}
// 出力は “earth” not found in string となります
参照元:http://www.php.net/manual/ja/function.stristr.php
graffiti on the web
この投稿へのコメント
コメントはまだありません。