如果没有数据,则显示大小为0的数组,而不是大小为1的数组(array(1){[0] => string(0)“”})|| PHP

I have this below code with three different conditions:

  1. "$json->clientip":["10.78.58.1", "10.75.22.12"] if the clientip is an array

  2. "$json->clientip":"10.74.10.1, 10.75.10.132, 10.75.10.152" if clientip is a string separated by comma

  3. "$json->clientip":"10.74.10.1, " if clientip is a string with Single value

All the three cases is returning an array.

However when i am trying below condition:

"$json->clientip":""

it is returning me an array of size 1 but i want an array of size of 0 if there is no data. Can someone please help me with the logic or code, how can i do that

    switch (true) {
    case is_array($json->clientip):
        // Ips sent as a JSON array case ..
        // ...                      
        foreach ($json->clientip as $key => $ipValue) {
            $requestObj->clientip[] = (Utils::validatePattern(Utils::REGEXP_SECLOGS_IP, ((trim($ipValue)) ?? FALSE) )) ? trim($ipValue):NULL;
        }
        break;
        
    default:
        
        if (strpos($json->clientip, ',')) {
            // Comma separated IPs case ...
            // ..
            $tmp = explode(',', $json->clientip);
            foreach ($tmp as $key => $ipValue) {
                if (trim($ipValue) != '') $requestObj->clientip[] = (Utils::validatePattern(Utils::REGEXP_SECLOGS_IP, ((trim($ipValue)) ?? FALSE) )) ? trim($ipValue):NULL;
            }
        } else {
            // Single value case ..
            // ...
            $requestObj->clientip[] = trim($json->clientip);
        }                   
    } 
    
    var_dump($requestObj->clientip);die;

</div>