如何将两个变量合并为一个foreach?

时间:2014-01-09 18:29:06

标签: php mysql

如何将两个变量合并为一个foreach?

$variableOne
$variableTwo

foreach($? as $data)
{
    print data here from both variables
}

2 个答案:

答案 0 :(得分:2)

非常简单的伙伴:

$new_array = array_merge($variableOne, $variableTwo);
foreach($new_array as $data)
{
    print data here from both variables
}

答案 1 :(得分:0)

如果这些变量不是数组,您可以尝试

foreach(array($variableOne, $variableTwo) as $data){
  echo $data
}