Postgres Loop Through Array Php Format String 3