Returning an array to Twig from a plugin I'am writing a plugin that has to return an array of data, however Twig does not seem to accept it if I return a PHP array.  I don't want to use an explode in Twig to make it into an array.

I have seen in other plugins i can just call a function from twig like this.

{% set result = craft.winkelwagen.printWinkelWagen(currentUser.id) %}

{% for output in result %}
    {{ output }}
{% endfor %}


However, I get an array to string conversion error.  Does anyone know the correct way to do this?

Thanks in advance.
Your plugin should be able to handle PHP arrays just fine.

craft/plugins/myplugin/variables/MyPluginVariable.php

function getArray()
{
    return array('hi', 'there');
}


craft/templates/template.twig

{% set result = craft.myPlugin.getArray() %}
{% for item in result %}
    {{ item }}
{% endfor %}


The error you're seeing is likely because output itself is an array. If you have devMode enabled you can try a {{ dump(output) }} inside your for-loop to see what it actually is / contains.