Arrays |
[eluser]Milos[/eluser]
Hi, all. I am doing video tutorials, and I can't find any info about strange uses of arrays here. I can give you an example: // this is the code from controller: $data['name'] = "Milos"; // i transfer the $data to the view $this->load->view('home', $data); // this is the code from the view <?php echo $name; ?> So this is the thing that I do not understand. We have an array $data and 'name' is just a string index for that array. How can I access it like $name - normally it should be $data('name'); I didn't find any example like it in PHP manual so I don't know what is this. Thanks, Milos
[eluser]WanWizard[/eluser]
Behold the magic of the extract function: http://php.net/manual/en/function.extract.php
[eluser]Milos[/eluser]
[quote author="WanWizard" date="1293220365"]Behold the magic of the extract function: http://php.net/manual/en/function.extract.php[/quote] Thanks for answering. So you want to say that this function is implemented here already, when passing values from controller to the view?
[eluser]WanWizard[/eluser]
Yes, in the _ci_load() method of the Loader library, used when you call $this->load->view().
[eluser]Milos[/eluser]
[quote author="WanWizard" date="1293223738"]Yes, in the _ci_load() method of the Loader library, used when you call $this->load->view().[/quote] Thank you! |
Welcome Guest, Not a member yet? Register Sign In |