Jump to content

Need explanation of Data array inside an object


vincej

Recommended Posts

Hi - I'm following a course on CodeIgniter where the tutorial uses some syntax to describe an array inside and object.  I have never seen this syntax before for creating an array - specifically the way they splice together the $data variable with the name of the array ['title'] . It's easy enough to follow however, I was wondering why anyone would use it, if it was standard adn if it had any special relevance.  Thanks !

 


class Blog extends Controller{

function index()
{
$data['title'] = "My Bog Title";
$data['heading'] = "My Bog Heading"

$this->load->view('blog_view', $data)
}

}

Arrays can have numeric and alphanumerical keys, so they can be [1], [2], ['08'] or ['alphabet']. Arrays can be simply declared by setting one of its indices. It can be nicer to look at than say, $data = array('title' => "My Bog Title", 'heading' => "My Bog Heading");.

 

Am I missing something about your question?

 

http://www.php.net/manual/en/language.types.array.php

 

PS: Bog?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.