http://www.php.net/manual/en/function.pg-getlastoid.php
is what you're looking for. Every row in a postgresql database has a unique OID (object ID) which is assigned to it. So, by doing something like this:
$res = pg_exec($conn,"insert into table values ('value','value',number);
$oid = pg_getlastoid($res);
$res2 = pg_exec($conn,"select id from table where oid=$oid");
$id = pg_result($res2,0,"oid");