Never used smarty, but in PHP you can do:
<?php class foo { public function getId() { return (int)2; } } $array = array( 1 => array( "parent_id" => 14 ), 2 => array( "parent_id" => 15 ) ); $foo = new Foo; echo $array[(int)$foo->getId()]['parent_id'];
I have a type cast as an integer (int)$foo->getID() , because the $array indices are integers, enclosing them in brackets {} type castes them in strings.
(Maybe you should look at Foo::getID() and see if the string returns)
In smarty, then you can do something like this (theoretically, since I cannot check it in smarty):
{$array[(int)$foo->getId()]['parent_id']} //Also check if this works, but I suspect it shouldn't (the syntax it not valid PHP) {$array.(int)$foo->getId().parent_id}
source share