【问题标题】:concatenate array of images together in one sourcefile将图像数组连接到一个源文件中
【发布时间】: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 对象。谢谢

【问题讨论】:

标签: php arrays laravel


【解决方案1】:

&lt;canvas id="fullscreen" class="3dviewer" sourcefiles='@foreach($explodeItems-&gt;labstlfiles as $item){{asset("storage/uploads/stl/$item")}}|@endforeach ' width="960px" height="600px"&gt;&lt;/canvas&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-28
    • 2020-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多