【发布时间】:2020-02-08 08:35:06
【问题描述】:
我想在 foreach 循环中连接图像数组。我想在值之间插入| 的每个值。这些文件在文件夹 storage/uploads/stl 我期望的是这样的:
这是我迄今为止尝试过的。我在原始 PHP 中尝试过
$lstfile = $project->labstlfiles;
$explodeItems = json_decode($lstfile);
print_r($explodeItems);
Output array :
stdClass Object ( [labstlfiles] => Array ( [0] => scans.stl_1570736143.stl [1] => lower.stl_1570736143.stl [2] => stl.stl_1570736143.stl ) )
然后在这样的条件语句中循环:
<?php if (is_object($explodeItems)){ ?>
<?php foreach ($explodeItems->labstlfiles as $items) { ?>
<div class="view" style="background-color: yellow">
<canvas id="fullscreen" class="3dviewer" sourcefiles="{{asset("storage/uploads/stl/". $items . "|") }}" width="960px" height="600px"></canvas>
</div>
<?php }
}else{
echo '<h2> It is not array </h2>
}
?>
我得到的是数组的 3 个实例,每个文件都在一个 div 中工作。我想要一个源文件,将所有三个文件组合起来给我 3d 对象。谢谢
【问题讨论】: