Question: So I have this array of images pulling and the array's keys are just 0,1,2,3,4,5.... and whatnot...

How can I make the value in the 'id' column of that table the key, and keep 'link' as the value.

Associative Array, no? 

**Here is my PHP:**

```
$myImageID = $me['imageid'];

$findImages = "SELECT link FROM images WHERE model_id ='{$me['id']}'";
$imageResult = mysql_query($findImages) or die (mysql_error());

$myImages = array();
while($row = mysql_fetch_array($imageResult)) {
    $myImages[] = $row[0];
}

```

**Here is what I have:**

```
{
 [0] -> "http://website.com/link.jpg"
 [1] -> "http://website.com/li123nk.jpg"
 [2] -> "http://website.com/link3123.jpg"
}

```

**Here is what I want:**

```
{
 [47] -> "http://website.com/link.jpg"
 [122] -> "http://website.com/li123nk.jpg"
 [4339] -> "http://website.com/link3123.jpg"
}

```

Answer: 
Just select the id and make it the key to the array. It's that simple.

```
$findImages = "SELECT id, link FROM images WHERE model_id ='{$me['id']}'";
$imageResult = mysql_query($findImages) or die (mysql_error());

$myImages = array();
while($row = mysql_fetch_array($imageResult)) {
    $myImages[$row[0]] = $row[1];
}

```

FYI, [you shouldn't use `mysql_*` functions in new code](https://stackoverflow.com/q/12859942/). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [red box](https://www.php.net/manual/en/function.mysql-connect.php)? Learn about [*prepared statements*](https://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://php.net/pdo), or [MySQLi](http://php.net/mysqli) - [this article](https://php.net/manual/en/mysqlinfo.api.choosing.php) will help you decide which. If you choose PDO, [here is a good tutorial](http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers).

You also wide open to [SQL injections](https://stackoverflow.com/q/60174)
```
  $myImages[$me['id']] = $row[0];

```