Re: [SMARTY] Problems with appending values to an array

From: Date: Wed, 19 Feb 2003 15:44:38 +0000
Subject: Re: [SMARTY] Problems with appending values to an array
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7890@lists.php.net to get a copy of this message
On Wed, Feb 19, 2003 at 04:27:22PM +0100, Joscha Feth wrote: > Hi, > > I have a problem appending another values (key => value pairs) to an already > assigned array. > > ---------------8<------------------ > $array1 = array( > "bla" => "foo", > "bar" => "baz" > ); > > $s->assign("arr",$array1); > > > $array2 = array( > "fasel" => "blubb", > "foobar" => "foofoo" > ); > > $s->append("arr",$array2); > ---------------8<------------------ > > > Already turns out in (debug console): > ------------------------------------- > {$arr} Array (3) > bla => foo > bar => baz > 0 => Array (2) > fasel => blubb > foobar => foofoo > > > But what I need is: > ------------------- > {$arr} Array (4) > bla => foo > bar => baz > fasel => blubb > foobar => foofoo > > > Why does Smarty create a new key there? Seems to be a bug for me, as I > append the values... you can only apppend one value at a time, i guess. and you cannot supply your own keys, i'm afraid. maybe we can extend append() to handle this. you have to build your array in php and assign it then to smarty for now. > append_by_ref results in the same! > > Greets, > Joscha

« previous php.smarty.general (#7890) next »