<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>enginiya</author_name>
  <author_url>https://blog.hatena.ne.jp/enginiya/</author_url>
  <blog_title>エンジニ屋.com(エンジニヤドットコム)</blog_title>
  <blog_url>https://enginiya.com/</blog_url>
  <categories>
    <anon>PHP</anon>
  </categories>
  <description>array_searchを使っていて、ちょっとした落とし穴にはまってしまったことあったので、 メモ程度ですが記事にしたいと思います。 先ずは、array_searchの使い方を簡単に説明すると、第二引数で指定した配列の中から、第一引数と同じ文字列が存在した場合、一致した値の配列のキーを渡してくれます。 &lt;サンプルコード&gt; $test_array = [&quot;サル&quot;,&quot;トラ&quot;,&quot;パンダ&quot;]; $result = array_search(&quot;パンダ&quot;,$test_array); print_r($result); 結果 2 もし配列の中と値が一致しない場合は、falseを返します。 if文で条件分岐後…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fenginiya.com%2Fentry%2F2021%2F11%2F26%2Ffunction_array_search&quot; title=&quot;【PHP】array_searchを使用する際の注意点　 - エンジニ屋.com(エンジニヤドットコム)&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2021-11-26 22:53:20</published>
  <title>【PHP】array_searchを使用する際の注意点　</title>
  <type>rich</type>
  <url>https://enginiya.com/entry/2021/11/26/function_array_search</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
