Welcome Guest, Not a member yet? Register   Sign In
what is worng with this foreach and for loops
#1

[eluser]BaRzO[/eluser]
Hi all,

I am having a problem with my code.
My controller.
Code:
<?php

class Welcome extends Controller {

    var $settings;

    function Welcome() {
        parent::Controller();
        $this->load->database();
        $this->load->library('theme_lib');
        $this->load->helper('url');
    }

    function index() {
        $this->theme_lib->_add_js("/* js comment */"); // this works
        for ($i=0; $i<=5; $i++) {
           $this->theme_lib->_add_js("/* js comment */"); // does not work
        }
    }
}

and my theme_lib
Code:
&lt;?php

class Theme_lib {

    var $CI;
    var $_embed_js = '';

    function Theme_lib() {
        $this->CI = & get_instance();

        log_message('debug', __CLASS__ . " Class Initialized");
    }
    function _add_js($js, $type = 'embed') {
        if ($type == 'embed') {
            $this->_embed_js .= $js . "\n";
        } else {
            $this->_js[] = $js;
        }
    }
}

Why this _add_js function does not work in for or foreach loops ?
Pls Help...
Thnks.


Messages In This Thread
what is worng with this foreach and for loops - by El Forum - 08-13-2010, 08:11 PM
what is worng with this foreach and for loops - by El Forum - 08-13-2010, 09:22 PM
what is worng with this foreach and for loops - by El Forum - 08-13-2010, 09:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB