title: how to know whether key exists in Json string
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1966169/how-to-check-if-an-array-element-exists">How to check if an array element exists?</a>  </p>
  </blockquote>
  
  
  
  <p>apologize if i am wrong,I am new to PHP, Is there any way to find out whether key exists in <code>Json</code> string after decoding using <code>json_decode</code> function in PHP.</p>
  
  <pre><code>$json = {"user_id":"51","password":"abc123fo"};
  </code></pre>
  
  <p>Brief: </p>
  
  <pre><code>$json = {"password":"abc123fo"};
  $mydata = json_decode($json,true);
  user_id = $mydata['user_id'];
  </code></pre>
  
  <p>If json string doesn't consist of user_id,it throws an exception like <code>Undefined index user_id</code>,so is there any way to check whether key exists in Json string,Please help me,I am using <code>PHP 5.3 and Codeigniter 2.1 MVC</code> Thanks in advance</p>