smarty tip

$smarty->assign('name', 'nayana');라고 했을때

대문자로 만들기
{$name} {$name|strtoupper}
nayana NAYANA

배열 개수 확인
{$name_list|count} → Array

스마티는 배열을 넘길때 @를 사용한다.
{$name_list|@count} → Array

{$name_list|@print_r}
Array
(
[0] => nayana
[1] => yo
[2] => kim
[3] => lee
[4] => smith
) 1

키-값 치환하기
{$name_list|@array_flip|@print_r}

Array
(
[nayana] => nayana
[yo] => yo
[kim] => kim
[lee] => lee
[smith] => smith
) 1

문자 자르기
{$name|substr:'1':'3'}

문자 치환
{$name|str_replace:'naya':'nugu'}
-> nugu

이 나온다. 의도한 것은
str_replace($name, 'naya', 'nugu');
이지만 결과는
str_replace('shi', 'ko', $name);
이 된다.

그럼 이렇게 써보면 어떨까.
{'nugu'|str_replace:'naya':$name}
-> nuguya

원하는 결과이다.

{'/a|i|s/'|preg_replace:'?':$name}
→ n?y?n?


이런식으로 무한한 기능이 바로 스마티이다 ^^

by 나야나 | 2009/08/24 16:46 | JAVA:PHP | 트랙백 | 덧글(0)

트랙백 주소 : http://voyager.egloos.com/tb/4218431
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]

:         :

:

비공개 덧글

◀ 이전 페이지          다음 페이지 ▶