公司各部门联系电话
{hcTaglib:category id="197" item="vo" field="*"}
{php}
$contact_str = $vo['description'] ?? '';
$contact_phone = '';
$contact_fax = '';
$contact_email = '';
if(!empty($contact_str)){
$contact_arr = explode('##', $contact_str);
$contactList = [];
foreach ($contact_arr as $item) {
// 按 ':' 拆分成name和tel,限制为2部分,防止tel中有多余冒号
$parts = explode(':', $item, 2);
if (count($parts) == 2) {
$contactList[] = [
'name' => trim($parts[0]),
'tel' => trim($parts[1])
];
}
}
// 每2个一组分块
$chunkedList = array_chunk($contactList, 2);
}
{/php}
{/hcTaglib:category}
{foreach $chunkedList as $row}
{$row[0]['name']}
{$row[0]['tel']}
|
{if isset($row[1])}
{$row[1]['name']}
{$row[1]['tel']}
|
{else}
|
{/if}
{/foreach}