我的代码低于一切,但是我在结果末尾得到了多余的单词“ array”
$headings = ['heading one', 'heading two', 'heading three'];
$features_list = ['feature1', 'feature2', 'feature3'];
$content = array_map(null, $headings, $features_list);
使用类似的数组映射并使用以下代码解决结果
foreach ($content as $entry) { ?>
<tr>
<td>
<?php printf('<p><strong>%s</strong></p>', $entry[0]); ?>
</td>
<td>
<p class="xp-options">
<?php
if ($entry[1][2] == 1) {
echo '<i class="fa fa-check-circle"></i>';
} else {
echo '<i class="fa fa-times-circle"></i>';
}
?>
<?php printf($entry[1][0]); ?>
<?php if (!empty($entry[1][1])):?>
<a href="#" data-toggle="tooltip" title="<?php echo $entry[1][1] ?>"><i class="fa fa-question-circle"></i></a>
<?php endif; ?>
</p>
</td>
</tr>
<?php }
?>
数组结果在下面,带有print_r
$content = array_map(null, $headings, $features_list[$a]);
echo '<pre>';
print_r($content); die;
Array
(
[0] => Array
(
[0] => Heading One
[1] => Array
(
[0] => Feature 1
[1] => Tool Tip for Demo
[2] => 0
)
)
[1] => Array
(
[0] => Heading Two
[1] => Array
(
[0] => Feature2
[1] =>
[2] => 1
)
)
[2] => Array
(
[0] => Heading Three
[1] => Array
(
[0] => Feature 3
[1] =>
[2] => 0
)
)
[3] => Array
(
[0] =>
[1] => Array
(
[0] => Feature 4
[1] =>
[2] => 1
)
)
)
请帮助我找到问题,为什么我最后要获得阵列。我还有其他函数可以用来替换array_map()吗?预先特别感谢。