Welcome Guest, Not a member yet? Register   Sign In
global var declaration not working
#1

[eluser]jerry01[/eluser]
i'm trying to have a list i can use throughout my controller. i can't find a way of getting it to work with "var"

can anyone comment?

it seems that var does not really pass the full info.


Code:
class Controller extends CI_Controller
{

    var $field_list = array('f1','f2','f3','f4','f5','f6');
...

    function index()
    {
        foreach($this->field_list as $field):
            print("------&gt;" + $field + "<BR>");
        endforeach;

the outcome of that is just a bunch of zeroes..
#2

[eluser]samitrimal[/eluser]
use dot operator instead of plus operator
Code:
foreach($this->field_list as $field):
            print("------&gt;" . $field . "<BR>");
        endforeach;
#3

[eluser]jerry01[/eluser]
ah thanks for that

duh! too much time working with python and java........

Sad
#4

[eluser]jerry01[/eluser]
ok this is the way to do it, if anyone is interested (some day)

Code:
foreach($this->field_list as $k => $p):

                print("------&gt;" . $p . "<br>");

            endforeach;




Theme © iAndrew 2016 - Forum software by © MyBB