Question: I have recently been employed at an office where they use a lot of php in their work, most of my development background is HTML, CSS, Jquery, Wordpress and Angularjs, I have an idea behind the logic of some of php but was just wondering if anyone can enlighten me as to what this code below actually means/does?

```
return (isset($rs[0][0]) ? $rs[0][0] : "");

```

It is located within this function that calls the database and returns values. 

```
function get_temp($table, $field){
    global $db;
    $sql="select $field from $table";
    $rs=$db->select($sql);
    return (isset($rs[0][0]) ? $rs[0][0] : "");
}

```

I feel that is selecting one value from an array within an array but I cannot find any sources to confirm this so was hoping someone on here could help me out or at least point me in the right direction if I am wrong. The reason I believe this is the case is because if I pass the `$field` variable more than one result it will always only return the first one, if this is the case it would also be helpful to me if someone could suggest a way to get all of the results, whenever I simply try:

```
return $rs

```

It simply returns "Array".

Answer: 
You can draw a timeline like this on paper to aid in understanding algorithms:

[![](https://i.stack.imgur.com/HB2Vy.png)](https://i.stack.imgur.com/HB2Vy.png)

It shows how the variables (rows) get transformed in the various iterations (columns)

Sorry for the pen & paper quality ;-)
You said you've worked with the recursive case, but just to make sure we're on the same page, consider the generic case of the function returning the numth number in the sequence (0th is 0, 3rd is 2, 7th is 13, etc):

```
def rfib(num):
    return num if num <= 1 else rfib(num - 1) + rfib(num - 2)

```

Now, the generic iterative version:

```
def ifib(num):
    a = 0
    b = 1
    for _ in range(num):
        a, b = b, a + b
    return a

```

I think the example you posted might have confused you where it split the b = a + b step into two steps. But it's really just doing the same thing as the recursive version, which is adding the previous two numbers in the sequence.