Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.