Smarty Object Function with Associative Array Unexpected “=>”, expected one of: “”,“” , “)”'-Collection of common programming errors
I am having a problem with Smarty passing a PDO Object to Smarty it just doesn’t like =>
. Is there a trick to get around this problem?
Here is he error:
{assign var='brgdatas' value="{$brgObj->fetchOneBrg(array('id'=>{$ststres[ststval].to_id}'))}"}" - Unexpected "=>", expected one of: "","" , ")
Here is the code I am working with:
{section name=ststval loop=$ststres}
{if $ststres[ststval].type == 2}
{assign var='brgdatas' value="{$brgObj->fetchOneBrg(array('id'=>{$ststres[ststval].to_id}'))}"}
The correct answer Update:
Is to add [] between the associative array and remove the quotes like so.
{assign var='brgdatas' value=$brgObj->fetchOneBrg(['id'=>$ststres[ststval].to_id])}