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