shank
shank

Reputation: 373

echo two arrays dynamically in php

I want to print two array values dynamically like for every constant value the variable should change. there are 5 constant values like we do, we jockey, we create, we innovate, we sell and variable values are ideas,brands,creative,campaigns.

(Constant) we do (flip- vertical) ideas,brands,creative,campaigns
(Constant) we jockey (flip- vertical) ideas,brands,creative,campaigns

...

for every constant part the variable part has to change. where i am going wrong? The code below prints properly but the constant part should not change.`

I am using this code:

<?php 
     $bikes=array("DO","JOCKEY","CREATE","INNOVATE","SELL");
     foreach ($bikes as $items) {
        $cars=array("IDEAS","BRANDS","CREATIVE","CAMPAIGNS");
        for($i=0;$i<10;$i++)
        {
           echo "  <a class='blue' style='text-decoration:none' href=''>WE $bikes[$i] $cars[$i]</a>";
        }
     }

?>

Upvotes: 0

Views: 103

Answers (1)

Beto L&#243;pez
Beto L&#243;pez

Reputation: 91

<?php 

    $bikes=array("DO","JOCKEY","CREATE","INNOVATE","SELL");
    $cars=array("IDEAS","BRANDS","CREATIVE","CAMPAIGNS");
    foreach ($bikes as $bike) {    
        foreach($cars as $car){
            echo "<a class='blue' style='text-decoration:none' href=''>WE ".$bike." ".$car."</a><br>";
        }
    }
?>

Upvotes: 2

Related Questions