php - Get ASSOC array value by numeric index -


In all instances of codeigniter questions, I think the name of the field should be known to get its value.

  $ query = $ this- & gt; Db- & gt; Query ("selection title, name, table of body"); Foreign exchange ($ query-> result () as $ line) {echo $ line-> Title; Counterpart $ line-> Name; Counterpart $ line-> the body; }  

For example, if I want to get the title , then I would like to type in row-> Title will be used to get the title to use the index such as $ line [0] ? Use result_array to query query result as pure array Is

  $ query = $ this- & gt; Db- & gt; Query ("selection title, name, table of body"); $ Result = $ query- & gt; Result_are (); Forex Currency ($ Res $ as Res) {ebb $ res ['title']; Echo $ res ['name']; Echo $ res ['body']; }  

If you want to access from the index then use the array_values:

  $ result = $ query-> Result_are (); Forex Currency ($ result as res $) {$ r = array_values ​​($ res); Echo $ r [0]; Echo $ r [1]; Echo $ r [2]; }  

Comments