how to check foreach index is integer or string in smarty?
how to check foreach index is integer or string in smarty?
<?php
$arr = array(9 => 'Tennis', 3 =开发者_JAVA百科> 'Swimming', 8 => 'Coding');
$smarty->assign('myArray', $arr);
?>
Could you post an example on why you need to know that?
In general, you can use the PHP functions is_string
and is_integer
to detect types.
Also use {php}{/php}
to use PHP code inside the Smarty templates.
精彩评论