“implode” filter: return original data on non-array

8 months ago

tpr
Member | 55
+
-4
-

How about returning the original data if non-array data is passed to the “implode” filter (eg a string)?
Now it generates a PHP warning.

This could come handy in cases when you don't know if you apply it to an array or a simple string.

Last edited by tpr (2017-03-08 16:26)

8 months ago

greeny
Member | 406
+
+4
-

You should always know with which data type you are working. If you are not sure, you can always do $this->template->array = (array) $arrayOrString; which solves your problem.

Last edited by greeny (2017-03-10 09:27)

8 months ago

tpr
Member | 55
+
0
-

I use Latte standalone and the data I use may come in either formats. I've already made my own filter that does the same you suggested but I thought it would be better having this built-in.