我从DB获取了一个返回用户地址的字符串,我想截断这个的第一部分只留下 城市和国家。 p>
存储的strig就像: p>
514 S. Magnolia St. - 32806 - Orlando - FL
< / code> pre>
我希望它是: p>
Orlando - FL
code> pre>
\ n 如何使用Twig? 我得到了使用Doctrine p>
public function profileAction($ query)
{
$ user = $ this-&gt; getDoctrine()
- &gt;获取对象的数据 ; getRepository('AppBundle:User')
- &gt; find($ query);
if if(!$ user){
throw $ this-&gt; createNotFoundException(
'User'。$ user。 '找不到。'
);
}
返回$ this-&gt; render('profile / profile.html.twig',[
'user_info'=&gt; $ user,
]) ;
}
code> pre>
我使用常规Twig获取值: {{user_info.address}} code> p> \ n div>