如何使用php数组echo

时间:2017-03-03 08:13:04

标签: php arrays echo

如何使用PHP数组echo?

我不知道如何回应阵列。

如果数组数据是流..

Array ( 
  [0] => Array ( [0] => red [1] => blue) 
  [1] => Array ( [0] => 100 [1] => 105 ) 
  [2] => Array ( [0] => AB [1] => AC ) 
) 

我想接下来回应......

red/100/AB

red/105/AB

red/100/AC

red/105/AC

blue/100/AB

blue/105/AB

blue/100/AC

blue/105/AC

..

3 个答案:

答案 0 :(得分:2)

    for( $i = 0 ; $i < count($arr) ; $i++ ){
       echo $arr[0][$i]."/".$arr[1][$i]."/".$arr[2][$i] ."<br/>";
    }

答案 1 :(得分:0)

$any_array = array('var1'=>'data1','var2'=>'data2',etc);

print_r($any_array);

如果你想在html页面中格式化

echo '<pre>';
print_r($any_array);
echo '</pre>';

答案 2 :(得分:0)

/**
 *   Array ( [0] => Array ( [0] => red [1] => blue) [1] => Array ( [0] => 100 [1] => 105 ) [2] => Array ( [0] => AB [1] => AC ) )
 *
 */
public function test(){

    $arr = [['red', 'blue'],[100, 105],['AB', 'AC']];


    foreach($arr[0] as $v){

        foreach($arr[1] as $v2){

            foreach($arr[2] as $v3){
                echo $v.'/'.$v2.'/'.$v3;
                echo '<br/>';
            }

        }

    }

}

//试一试