dongxu7121 2018-06-26 17:18
浏览 51

如何删除prev foreach数据

foreach ($products as $product) {
    echo "SIZE (X х Y х Z),mm: ";
    $myf = [8,4,5]; // my custom fields is X,Y,Z and print it           
    foreach($product->customfields as $field){ // get fields
        if (in_array($field->virtuemart_custom_id, $myf)) {
            $output[] = $field->customfield_value;
        }
    }
    echo implode('x', $output); // is getting re-assigned each time. So whatever the problem is, it is a result of whatever $output is getting assigned with.
}

in second product I have this data from first product

SIZE (X х Y х Z),mm: 280x260x350x290x325x435 (need 290x325x435 only!). on each products I have all previous XYZ data from all previous products.

Very mistiq. pls help print data 1 XYZ to 1 product only :)

I thinks implode not correct method

  • 写回答

1条回答 默认 最新

  • dqdtgiw4736 2018-06-27 06:44
    关注

    Just after this line

    echo implode('x', $output);
    

    Add this line

    unset($output);
    

    What this does is this will reset your $output to an empty array. No longer your $output has the previous data.

    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记