Freedom-n-Democrazy Posted October 9, 2011 Share Posted October 9, 2011 Is there a shorter way to achieve this in a single foreach()? foreach ($_SESSION['cart']['content']['sizes'] as $content); foreach ($_SESSION['cart']['content']['sizem'] as $content); foreach ($_SESSION['cart']['content']['sizel'] as $content); I am thinking something like: foreach ($_SESSION['cart']['content']['sizes'] && $_SESSION['cart']['content']['sizem'] && $_SESSION['cart']['content']['sizel'] as $content); or foreach ($_SESSION['cart']['content'] = ['sizes'] || ['sizem'] || ['sizel'] as $content); Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted October 9, 2011 Share Posted October 9, 2011 No. A foreach does not contain a conditional component. If you need a conditional, use a for-loop or while-loop. Quote Link to comment Share on other sites More sharing options...
Freedom-n-Democrazy Posted October 9, 2011 Author Share Posted October 9, 2011 No problem. Thanks, Nightslyr. Quote Link to comment 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.