How to create a Dynamic Associative array in PHP, from $_POST values? : I am trying to create php array (associative) declaration for non-empty key-value pairs only, which I am getting from $_POST. Any guesses, how to do this ?

    $my_array = [
    
    "k1"=>"$val1",
    "k2"=>"$val2",
    "k3"=>"$val3",
    "k4"=>"$val4"
    
    ];

But, if $val4 & $val3 are empty / NULL / does'nt exist, then :


    $my_array = [
    
    "k1"=>"$val1",
    "k2"=>"$val2"
    
    ];

Thanks