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: 
Each value in the Fibonacci sequence is the sum of the preceding two values. `f1` and `f2` merely track those previous two values.

By assigning the value of `f2` to `f1` and the previous result `add` to `f2`, the algorithm shifts along the sequence to only keep the last two calculations.

In steps:

1. `f1 = 1`, `f2 = 0`, result `add = 1`
2. `f1 = 0`, `f2 = 1`, result `add = 1`
3. `f1 = 1`, `f2 = 1`, result `add = 2`
4. `f1 = 1`, `f2 = 2`, result `add = 3`
5. `f1 = 2`, `f2 = 3`, result `add = 5`
6. `f1 = 3`, `f2 = 5`, result `add = 8`

etc., with the value from `add` shifting to `f2` and the value that was in `f2` shifting to `f1` each step.
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 ;-)