title: How to read login details from external json file?
body: <p>I am having difficulty to read username and password from external json file. I want to match username and password from user inputs with json username and password.Can anyone help me please? Thanks</p>
  <p>my.json</p>
  <pre><code>[
    {
      &quot;username&quot;:&quot;user@email.com&quot;,
      &quot;password&quot;:&quot;123456&quot;
    },
    {
      &quot;username&quot;:&quot;newuser@email.com&quot;,
      &quot;password&quot;:&quot;98765&quot;
    }
  ]
  </code></pre>
  <p>php codde</p>
  <pre><code>$username = $_POST['username'];
          $password = $_POST['password'];
          $JSON = file_get_contents(&quot;my.json&quot;);
          $jsonIterator = new RecursiveIteratorIterator(
                          new RecursiveArrayIterator(json_decode($JSON, TRUE)),
                          RecursiveIteratorIterator::SELF_FIRST);
  
         foreach ($jsonIterator as $key =&gt; $val) {
      
          if($val==$username &amp;&amp;  $val == $password) {
              print &quot;found&quot;;
              $_SESSION['signin'] = $username
          
          }
  </code></pre>