好的,问题是我有多个产品需要显示注释。如果不为每种产品编写以下全部代码,最好的方法是将注释回显给多个产品?
<?php if ($data['header']['group_code'] == 'R088X') { ?>
<li><span>Printers:</span> Wipe the allocated print area before print application with methylated spirit.</li>
<?php } ?>
我已经尝试过以下认为它不起作用......
<?php
$data = array((['header']['group_code'] == 'R088X', 'R129X'));
if (in_array(['header']['category'] == 'R088X', $data)) { ?>
<li><span>Printers:</span> Wipe the allocated print area before print application with methylated spirit.</li>
<?php } ?>
任何建议都会感激不尽:)
答案 0 :(得分:2)
$data = array (
'header' => array (
'group_code' => array (
'R088X',
'R129X'
)
)
);
当涉及到数组时,PHP不是最好的编程语言!
但是,如果您运行的是PHP 5.4,则可以这样写:
$data = [
'header' => [
'group_code' => [
'R088X',
'R129X'
]
]
];
答案 1 :(得分:2)
除了@Darkzaelus的回答,在PHP 5.4中你可以这样做:
$data = [ 'header' => [ 'group_code' => [ 'R088X', 'R129X' ] ] ];