Php 如何删除prev foreach数据

Php 如何删除prev foreach数据,php,arrays,regex,arraylist,joomla,Php,Arrays,Regex,Arraylist,Joomla,在第二个产品中,我有第一个产品的数据 尺寸(XƏYƏZ),毫米:280x260x350x290x325x435(仅需要290x325x435!)。 在每个产品上,我都有以前所有产品的所有XYZ数据 非常迷糊。请帮助打印数据1 XYZ到1只产品:) 就在这一行之后,我认为内爆不是正确的方法 foreach ($products as $product) { echo "SIZE (X х Y х Z),mm: "; $myf = [8,4,5]; // my custom fiel

在第二个产品中,我有第一个产品的数据

尺寸(XƏYƏZ),毫米:280x260x350x290x325x435(仅需要290x325x435!)。 在每个产品上,我都有以前所有产品的所有XYZ数据

非常迷糊。请帮助打印数据1 XYZ到1只产品:)

就在这一行之后,我认为内爆不是正确的方法

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.
}
echo implode('x', $output);
添加这一行

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.
}
echo implode('x', $output);

这将把
$output
重置为空数组。您的$output不再具有以前的数据。

上一个是什么?问题是什么?previous product.继承所有previous products的数据-XYZ直到不理解您的问题isin 3 product info我获取组合数据XYZ1XYZ2XYZ3,但必须仅为XYZ3,请删除组合数据我可以查看$products的数据吗?我想让它运行得很好,谢谢super@boniq如果这解决了您的问题,您可以将其标记为已解决。