Postgresql Iterate Over Json Array Length Php