在手动将额外的列“CAD 数据”附加到带有表格数据的多维数组后,不幸的是,我在“CAD 数据”列之前得到了这个糟糕的 [weight] 列。
实际上我只是想再次删除输出前的整个 [weight] 列。我尝试了几件事,但没有成功。
Array (
[row_0] => Array (
[col_0] => Order number
[col_1] => Size
[weight] => 1
)
[row_1] => Array (
[col_0] => 502 1001
[col_1] => 20
[weight] => 2
)
[row_2] => Array (
[col_0] => 502 1002
[col_1] => 25
[weight] => 3
)
[row_3] => Array (
[col_0] => 502 1003
[col_1] => 30
[weight] => 4
)
)
在我的代码下面:
<?php
$rows = $element['#object']->field_product_data_table['und'][0]['tabledata']['tabledata'];
$header = array_shift($rows);
$attributes = array(
"id" => "tablefield-0",
"class" => array("tablefield")
);
// append CAD data column
if (array_key_exists('und', $element['#object']->field_product_step_data)) {
$header[] = t('CAD data');
// make index of all entries in table
$entry_row_id_index = array();
foreach ($rows as $row_id => &$row) {
foreach ($row as $entry) {
$entry_row_id_index[$entry] = $row_id;
}
}
$step_files = $element['#object']->field_product_step_data['und'];
// add step-file to entry to rows with corresponding order number
$max_row_length = 0;
foreach ($step_files as &$file) {
if (array_key_exists($file['description'], $entry_row_id_index)) {
$orderNumber = $file['description'];
$row_id = $entry_row_id_index[$orderNumber];
$rows[$row_id][] = '<a href="#" class="step-file" data-filename="' . $file['filename'] . '" data-ordernumber="' . $orderNumber . '"></a>';
$row_length = count($rows[$row_id]);
if ($row_length > $max_row_length) $max_row_length = $row_length;
}
}
// fill rows so all have same length
foreach ($rows as $row_id => &$row) {
for ($i = count($row); $i < $max_row_length; $i++) {
$row[] = '';
}
}
}
?>
有只小跳蛙
慕妹3146593