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

Notice: This thread is very old.
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)

greeny
Member | 405
+
+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)

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.