連想配列(ハッシュ)で作ったツリー構造の中に、ある配列(要するに部分木)が含まれているかをチェックする処理を実装しようと思ったときに、ふと==による配列の比較と===による配列の比較はどう違うのだろうと疑問が浮かんだ。==と===の違いについては、以前『厳密な比較 [PHP]』で詳しく調べてみたものの、配列の比較はあまり詳しく見ていなかった。 そこで==と===で配列の比較をした場合の違いを詳しく見てみたところ、意外なことがわかった。 まずは以下の例でどちらもtrueになることを確認する。 <?php $a = array( 'a' => 'x', 'b' => 'y', ); $b = array( 'a' => 'x', 'b' => 'y', ); var_dump($a == $b); var_dump($a === $b); ?> bool(true
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く