Scripts Posted April 30, 2007 Share Posted April 30, 2007 new to php. working on my first php script.. this: $arr=array("xxx"=>"fff","yyy"=>"ggg"); foreach($arr as $value) echo $value; echos fffggg but i want the names(xxx,yyy) too. something like this: $arr=array("xxx"=>"fff","yyy"=>"ggg"); foreach($arr as $value) echo $value_name . $value; how? ??? Link to comment https://forums.phpfreaks.com/topic/49278-solved-foreach-name-of-current-item-of-associative-array/ Share on other sites More sharing options...
neel_basu Posted April 30, 2007 Share Posted April 30, 2007 <?php $arr=array("xxx"=>"fff","yyy"=>"ggg"); foreach($arr as $key => $value) { echo $key." => ".$value; } ?> Link to comment https://forums.phpfreaks.com/topic/49278-solved-foreach-name-of-current-item-of-associative-array/#findComment-241466 Share on other sites More sharing options...
Scripts Posted April 30, 2007 Author Share Posted April 30, 2007 works like a charm. Thanks neel ! Link to comment https://forums.phpfreaks.com/topic/49278-solved-foreach-name-of-current-item-of-associative-array/#findComment-241470 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.