我更喜欢在 symfony2 中使用 PHP 模板引擎而不是 Twig,因为它具有一定的灵活性,而且我更习惯了。
例如,在打印一些东西时,我会喜欢使用“三元 If”之类的东西。
我现在的问题是,我的数据在模板上呈现为对象。使用 (array) 似乎没有帮助,因为我最终得到了类似的东西;
array (size=4)
'�news\newsBundle\Entity\News�id' => int 1
'�news\newsBundle\Entity\News�title' => string 'News title 1' (length=12)
'�news\newsBundle\Entity\News�body' => string 'Some body text' (length=14)
'�news\newsBundle\Entity\News�createdDate' =>
object(DateTime)[306]
public 'date' => string '2014-11-05 19:41:48.000000' (length=26)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/London' (length=13)
如何获得像普通数组一样的结果,例如 array('id'=> int 1) 没有名称空间的东西。
提前致谢