[PHP] Foreach Parsing Parameters

Status
Not open for further replies.

Livar

Now 35% cooler!
Oct 15, 2010
846
86
Hey guys, Livar here again. Got a question, been doing a CMS using RainTPL, just one thing is on my mind, rather than setting parameters manually for e.g:

PHP:
$this->assign('var1', 'lol');

doing someret like

PHP:
foreach($Application->configurationInformation as $configInfo)
{
   $this->assign($configInfo, $Application->configurationInformation);
}

hopefully someone will understand
 

Xenous

o shi
Nov 15, 2011
383
101
If you have like all your parameters in an array like
PHP:
<?php
 
    $params = Array('one' => '1', 'two' => '2');
    foreach($params as $value => $replace)
    {
        $class->Assign($value, $replace);
    }
 
?>
It should work
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
I'm thinking something like this should do, not entirely sure.

PHP:
<?php
$foo = array( "var1" => "lol",
              "var2" => "rofl",
              "var3" => "pmsl",
              "var4" => "umad",
              "var5" => "trolol"
            );
 
foreach ( $foo as $k => $v )
{
    $this->assign( $k, $v );
}
?>
 
Status
Not open for further replies.

Users who are viewing this thread

Top