Wednesday, May 9, 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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...