This is very stupid question and I can't believe that im asking about something simple like this.
Im using db->get['table']->result()
to get data from table.
Table schema looks like this: table(id, col1, col2).
db->get['table']->result()
returns something like this (print_r):
Array
(
[0] => stdClass Object
(
[id] => 1
[col1] => "id 1 col 1"
[col2] => "id 1 col 2"
)
[1] => stdClass Object
(
[id] => 2
[col1] => "id 2 col 1"
[col2] => "id 2 col 2"
)
[2] => stdClass Object
(
[id] => 3
[col1] => "id 3 col 1"
[col2] => "id 3 col 2"
)
}
Now i need to get col2 value from row that has id=2, i want to do it without "foreach" loop.
I thought i can do it like this:
$valueThatINeed = $myArray[2]->col2;
This is wrong and i know why its wrong.
Question is - how to directly get that what i need without loop?