How to ignore fields if empty?

I found one solutions and it works, just in case someone could have the same question, I know that the response could be with an:

if(input==""){

}

But the problem was that I’m inserting every model in an object, so if the fields are empty, it insert in the object empty values, so I just did this:

if ($single_model['car_model'] != "") {
array_push($models_to_insert, $single_model);
} else {}

because if no model name is added in the first input and user clicks “update” or “publish” button, means that user don’t want/need another model

Not sure if it’s the best way but it works

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)