Postgres Loop Through Array Php Functions Syntax