Re: [PHP] Passing objects as a reference and extracting the indexof an associative array.

This is a discussion on Re: [PHP] Passing objects as a reference and extracting the indexof an associative array. within the PHP General forums, part of the PHP Programming Forums category; Webmaster wrote: > Hi, > > i am using the smarty template engine. > Here is the problem that I ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-04-2003
John W. Holmes
 
Posts: n/a
Default Re: [PHP] Passing objects as a reference and extracting the indexof an associative array.

Webmaster wrote:

> Hi,
>
> i am using the smarty template engine.
> Here is the problem that I would like to ask about:
>
> function initTop(&$page, $array)
> {
> for ($i=0; $i<sizeof($array)
> {
> $page->assignVars(, $array[$i])
> }
> }
>
>
> The function is supposed to know which object's attributes she is supposed
> to change. Do I have to pass the object as a reference? Have never worked
> with References before.
>
> The array is supposed to be associative.
> The funcion assignVars() is called like this:
>
> $objektname->assignVars("indexname of ass. array", $arraywert);
>
> How do I get the indexname for each arrrayvalue, so I can pass it to the
> function assignVars?


There is no "assignVars" method within Smarty. Are you using something
else overtop of it?

You can assign the whole array to Smarty like this:

$smarty->assign('some_name',$some_array);

Then, say you have $some_array['one'] = "Bob", you'd use a placeholder
like {$some_name.one} to get the value "Bob" in your template.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:44 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0