php中的多个数组



我想在foreach中组合三个数组,

$topic = explode(',',$data->topic);
$description = explode(',',$data->description);
foreach (array_combine($topic, $description) as $topic => $description) 
{
  echo $topic;
  echo $description;
}

它适用于两个数组,但我想要三个数组,因为我想传递$id = explode(',',$data->id);也在同一个数组,这是不可能使用array_combine,谁可以通过传递三个数组内相同的foreach帮助?

如果ID、主题和描述在提供给脚本的每个逗号分隔字符串中的顺序都是正确的,则可以使用以下命令创建一个由ID指定的单个数组键:

$id = explode(',',$data->id);
$topic = explode(',',$data->topic);
$description = explode(',',$data->description);
foreach($id as $key=>$val)
{
    $results[$val]['topic'] = $topic[$key];
    $results[$val]['description'] = $description[$key];
}

try this:

$newArray=array_merge($topic,$description,$third_array);
foreach($newArray as $key=>$value)
{
echo "$key- $value <br/>";
}

相关内容

  • 没有找到相关文章

最新更新