在php中动态回显两个数组

时间:2022-10-24 22:20:16

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.

我想动态打印两个数组值,就像变量应该改变的每个常量值一样。我们有5个不变的价值观,我们骑马,我们创造,我们创新,我们销售和变量价值观念,品牌,创意,活动。

(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>";
        }
     }

?>

1 个解决方案

#1


2  

<?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>";
        }
    }
?>

#1


2  

<?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>";
        }
    }
?>