title: How to get the first element value of a php object
body: <p>I am running pdo queries on different database tables and i am getting the following object result</p>
  
  <pre><code>object(stdClass)#6 (8) { 
      ["user_id"]=&gt; string(2) "36" 
      ["username"]=&gt; string(10) "nomoinc123"
      ....
  }
  </code></pre>
  
  <p>If i wanted to get the user_id i would have to write</p>
  
  <pre><code>$obj-&gt;user_id
  </code></pre>
  
  <p>However, i want to get user_id without having to explicitly write it so that when i do queries on other tables it would get that first Primary Key entry regardless of its name</p>
  
  <p>NB: All my Primary keys are written in this format name_id</p>