Jump to content

[SOLVED] What is $this => $something?


Nexy

Recommended Posts

Around this site, I see people with code that have:

 

$this => something here;

$this => something here;

$this => something here;

$this => something here;

etc....

 

Just wondering what is it called and any good place I can learn? If it just means greater than or equal to, then I don't understand why people use it this way. D:

Link to comment
https://forums.phpfreaks.com/topic/112221-solved-what-is-this-something/
Share on other sites

it's to specify a key/value pair for associative arrays. Example:

 

// keys are a, b, c values are 1, 2, 3
$blah = array('a' => 1, 'b' => 2, 'c' => 3);

// using a foreach loop to loop through array elements
foreach ($blah as $letter => $number) {
   echo "key: $letter value: $number <br />";
}

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.