php - How to get array key by value from array in smarty template? -


how array key value array in smarty template?

from below can last inserted key need particular key value in smarty.

{$array|@array_keys|@array_pop}  

assuming have following array:

$smarty->assign("array", [     '0' => 5,     'a' => 'abc',     'd' => 'xyz' ]); 

you can use in smarty:

{assign var="key" value='xyz'|array_search:$array}  {if $key !== false}     key {$key} {/if} 

to find key given value in array. of course work described array_search function


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -