<?php $sals=[ 'sachin' => 20000, 'dhoni' => 10000, ]; foreach($sals as$value){ print $value; } ?> | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

<?php $sals=[ 'sachin' => 20000, 'dhoni' => 10000, ]; foreach($sals as$value){ print $value; } ?>

could anyone say in the above code how to print Sachin and dhoni as output

20th Sep 2017, 5:36 AM
Srikanth iyer
Srikanth iyer - avatar
2 Answers
+ 3
<?php $sals=[ 'sachin' => 20000, 'dhoni' => 10000, ]; foreach($sals as $key => $value){ print $key." ".$value."<br>"; } ?>
20th Sep 2017, 6:23 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Maybe if we change a bit <?php $sals = array("sachin" => 20000, "dhoni" => 10000); print_r(array_keys($sals)); ?>
20th Sep 2017, 6:25 AM
Daniel
Daniel - avatar