Jump to content

[SOLVED] How to have two arrays in a foreach


JSHINER

Recommended Posts

Figured out the solution in part:

 

foreach ($page['references_amenities'] as $z) foreach ($APPLIANCES as $y) {

if($y == $z['Short']) { echo $z['Long'], ', ';}

}

 

However that displays: "Text, Text," - How can I get that LAST comma off?

i think this is what you're going for:

<?php
        foreach($page['references_amenities'] as $z){
                foreach($APPLIANCES as $y){
                        echo (($y == $z['Short']) ? ($z['Long']) : ());
                }
        }
?>

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.