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? ??? Quote 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; } ?> Quote 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 ! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.