Quicker way of doing this
16:16 22 Jan 2013

I'm using PDO to get an array of relations from my DB.

$dbRelaties = $dbh->query("SELECT pkRelatieId,naam,email FROM relaties");

in another function I need to access one specific row in this array. I've managed to do it like this:

$klant = array();
foreach ($dbRelaties as $dbRelatie) {
    if ($dbRelatie["pkRelatieId"] == $relatie) {
        $klant = $dbRelatie;
        break;
    }
}
sendMail("Subject", $klant);

The above code works. But I'm looking for a neater solution and a quicker one, the above code is called in a function and that function is called inside a loop. So every time it executes, it has to loop through $dbRelaties to get the correct relation.

Can anyone set me in the right direction?

php