Search code examples
phptwigtemplate-engine

Twig render does not take 2 arrays


I have Twig installed and im playing around with it a bit. I have two arrays the first holds site configurations like the name,title,keywords and another one that hold userdata when the user is logged in. The render function looks like this:

echo $pg->render('user_homepage.twig', $this->siteSettings,array("email"=>$_SESSION["email"]));

When I wirte

Welcome, {{ email }}

it only shows

Welcome, 

Site settings are available but not the email.

What am I doing wrong?


Solution

  • Try sticking those in one array

    echo $pg->render('user_homepage.twig', array_merge($this->siteSettings,['email'=>$_SESSION["email"]]));