pixeltrace Posted October 11, 2007 Share Posted October 11, 2007 hi, i have a code here $employeeAges; $employeeAges["Lisa"] = "28"; $employeeAges["Jack"] = "16"; $employeeAges["Ryan"] = "35"; $employeeAges["Rachel"] = "46"; $employeeAges["Grace"] = "34"; foreach( $employeeAges as $key => $value){ echo "Name: $key, Age: $value <br />"; } is there a way where in my foreach function i can omit 1 value of $employeeAges? example in my echo output i just wanted to have this Name: Jack, Age: 16 Name: Ryan, Age: 35 Name: Rachel, Age: 46 Name: Grace, Age: 34 is this possible? if not hope you could help me find other methods. thanks! Link to comment https://forums.phpfreaks.com/topic/72811-solved-need-help-on-foreach/ Share on other sites More sharing options...
trq Posted October 11, 2007 Share Posted October 11, 2007 <?php $employeeAges = array(); $employeeAges["Lisa"] = "28"; $employeeAges["Jack"] = "16"; $employeeAges["Ryan"] = "35"; $employeeAges["Rachel"] = "46"; $employeeAges["Grace"] = "34"; foreach( $employeeAges as $key => $value) { if ($key != 'Lisa') { echo "Name: $key, Age: $value <br />"; } } ?> Link to comment https://forums.phpfreaks.com/topic/72811-solved-need-help-on-foreach/#findComment-367201 Share on other sites More sharing options...
pixeltrace Posted October 12, 2007 Author Share Posted October 12, 2007 thanks! i didnt thought of that. its working now. Link to comment https://forums.phpfreaks.com/topic/72811-solved-need-help-on-foreach/#findComment-367525 Share on other sites More sharing options...
MasterACE14 Posted October 12, 2007 Share Posted October 12, 2007 press topic solved Link to comment https://forums.phpfreaks.com/topic/72811-solved-need-help-on-foreach/#findComment-367526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.