1

Well, i get it that - to access an method of an object of a class we use -> sign. But why is => sign used for ? Like in the below code its used for index and value of array:

<?php
    $a=array();

    $a['Ground'] = 5.95;
    $a['2nd day'] = 6.8;
    $a['night'] = 7;

    foreach ($a as $key => $value) {
   $msg = $key . '=' . $value .'<br>';
   echo $msg;
 }
    ?>

But what does it mean and when to use it?

perror
  • 7,071
  • 16
  • 58
  • 85
sudden kid
  • 15
  • 4
  • You can find the answer here: [Reference - What does this symbol mean in PHP?](http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) – Glorfindel Aug 08 '15 at 07:41

1 Answers1

4

=> sign is used to define array key value pair

$array = array("key1"=>"value1","key2"=>"value2");
Disha V.
  • 1,834
  • 1
  • 13
  • 21