Wednesday, 9 May 2018

php - What does $k => $v in foreach($ex as $k=>$v) mean?





Possible Duplicates:
What does “=>” mean in PHP?







What does $k => $v mean?


Answer



It means that for every key-value pair in the traversable variable $ex, the key gets assigned to $k and value to $v. In other words:



$ex = array("1" => "one","2" => "two", "3" => "three");
foreach($ex as $k=>$v) {
echo "$k : $v \n";
}



outputs:



1 : one
2 : two
3 : three

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...