Skip to content
Advertisement

How can i remove the key which contain the value white space in PHP, Laravel?

JavaScript

In the end there is no comma and no issue and in the database everything is fine

Now problem is that when i put a comma in the end there is a cell created in the database with whitespace

I know why this happening. The last key of the exploded array containing value is whitespace. But i want to omit or leave that empty key. How can i do that?

Advertisement

Answer

You should use array_filter() which will remove all empty keys from the array. So here is the code you should use:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement