Jump to content

Different ways to write foreach


Recommended Posts

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);

Link to comment
https://forums.phpfreaks.com/topic/248722-different-ways-to-write-foreach/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.