Do not select empty array PHP

I need to compare my two tables to know if they are empty and if so, not includ them in the result. I have the following code :

    public function parseJson()
    {
        foreach ($this->vendors as $row) {
            if ($row->legIntPurposes === $row->flexiblePurposes) {
                $this->results[] = [
                    'id'        => $row->id,
                    'name'      => $row->name,
                    'policyUrl' => $row->policyUrl,
                ];
            }else{
                $this->getEmptyVendors();
            }
        }
    }

    /**
     * @return null
     */
    public function getResults()
    {
        return $this->results;
    }

    public function getEmptyVendors()
    {
        if (empty($row['legIntPurposes']) && empty($row['flexiblePurposes'])) {
            return null;
        }
    }

Any idea on what I should return on my getEmptyVendors method ? thanks a lot

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *