Good day!

I am trying to insert an array of locations to my database.

```
$locations = array();
$locations = $_POST['loc'];
$loc = implode(", ", $locations);

```

When the array gets inserted into my database, the array items that do not have value (which in this case are empty) still go through, even though those input fields were disabled:

> 
> Test, Test, Test, , , , , , , , , , , , , , ,
> 
> 
> 

I've tried *string\_replace()*, *preg\_replace()*, *array\_splice()* and *unset()* to remove the empty values.

I want to be able to insert an array to the database that does not take in the empty values. I've tested over and over to check the length of the array with *count()* and it returns the max of my array which is 18 even though I only wanted 3.

Am I missing something in my code? Is there a procedure that I'm not following? I hope I did my best to describe my issue and hope this will better improve my thought process and the way I handle code. Thank you all so much!