title: Accessing PHP 7 Object Properties
body: <p>I have the following array</p>
  
  <pre><code>$arrdata = array("CTypeID","TypeName","CTYPES","CID","COURSES","CTypeID");
  </code></pre>
  
  <p>this array is subjected to a function: <code>Generic2DataSideBar($arrdata);</code>
  The definition of the called function is as follows:</p>
  
  <pre><code>function Generic2DataSideBar($data)
  {
      //a generic array for data..
      //var_dump($data);
      $sdata= array();
      //this is the function for generating depended data...
      $this-&gt;load-&gt;model("Commons");
      $dat="SELECT ".$data[0].",".$data[1]." FROM ".$data[2];
      $result=$this-&gt;Commons-&gt;LoadResultSet($dat);
      //Looping through the resultset
      foreach ($result as $key) {
          //get the number of departments
  
          $da="SELECT ".$data[3]." FROM ".$data[4]." WHERE ".$data[5]."='".$key-&gt;$data[0]."'";
          $dat=count($this-&gt;Commons-&gt;LoadResultSet($da));
  
          $r=array($key-&gt;$data[1], $dat);
          array_push($sdata, $r);
      }
      header("content-type: application/json");
      $sdata=json_encode($sdata);
      return $sdata;
  }
  </code></pre>
  
  <p>This function is working well in PHP 5.6.3 but when i upgraded to PHP 7, the line <code>$da="SELECT ".$data[3]." FROM ".$data[4]." WHERE ".$data[5]."='".$key-&gt;$data[0]."'";</code> brings a problem in that <code>$key-&gt;$data[0]</code> returns <code>''</code> All values are OK except that part. In PHP 7 can't one have something like <code>$key-&gt;"Data"</code> so long "Data" is a valid property name? Thanks</p>