Im having a little trouble in referencing indexes in arrays in Smarty. I believe that it is because the variable I am using as the index is a string. How may I cast this string as a integer within the template?
Thanks.
Im having a little trouble in referencing indexes in arrays in Smarty. I believe that it is because the variable I am using as the index is a string. How may I cast this string as a integer within the template?
Thanks.
I believe that it is because the variable I am using as the index is a string
I don't agree with that belief:
$arr = array('a');
$i = '0';
echo $arr[$i]; // echos a
I think the problem lies elsewhere. If you have further questions, you should include some of your code.
The documentation shows many usage examples, especially with regards to accessing array elements.
{$foo}        <-- displaying a simple variable (non array/object)
{$foo[4]}     <-- display the 5th element of a zero-indexed array
{$foo.bar}    <-- display the "bar" key value of an array, similar to PHP $foo['bar']
{$foo.$bar}   <-- display variable key value of an array, similar to PHP $foo[$bar]
{$foo[bar]}   <-- syntax only valid in a section loop, see {section}