Php 二维细枝阵列
我将卫星图像存储在mysql数据库中。该表具有纬度、经度等属性。我想将它们发送到细枝并显示为地图,我的php控制器如下所示Php 二维细枝阵列,php,mysql,arrays,symfony,twig,Php,Mysql,Arrays,Symfony,Twig,我将卫星图像存储在mysql数据库中。该表具有纬度、经度等属性。我想将它们发送到细枝并显示为地图,我的php控制器如下所示 public function highlightAction() { $highlighted=$this->getDoctrine() ->getRepository('AppBundle:satelliteImage') ->findAll(); $images = array(); fore
public function highlightAction()
{
$highlighted=$this->getDoctrine()
->getRepository('AppBundle:satelliteImage')
->findAll();
$images = array();
foreach ($highlighted as $key => $high) {
$images[$key] = base64_encode(stream_get_contents($high->getImage()));
}
return $this->render('satelliteImages/highlighted.html.twig',array(
'highlighted' => $highlighted,
'images' => $images
));
}
我的树枝代码如下:
<tbody>
{% for key,high in highlighted %}
<tr>
<img alt="Embedded Image" src="data:image/png;base64,{{ images[key] }}" />
</tr>
{% endfor %}
</tbody>
{键为%s,突出显示的%]中为高值}
{%endfor%}
我将图像显示为垂直阵列。如果有任何建议,我可能需要将它们显示为地图。
twig中的二维数组?您可以使用如下内容:
<table>
<tbody>
{% for key in 0..2 %}
<tr>
{% for key in 0..3 %}
<td>
<img alt="Embedded Image" src="data:image/png;base64,
{{ images[loop.parent.key*4 + key] }}" />
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{0..2%中的键为%1}
{0..3%中的键为%1}
{%endfor%}
{%endfor%}
阅读。您好,欢迎光临。你有什么问题?“显示为地图”是什么意思?数据库中有12幅卫星图像。当它们排列成3x4阵列时,它们将形成一张地图(因为它们是一个大区域的一部分)。现在我只能将它们显示为一个垂直列表……我对php或twigHi没有太多知识,谢谢。它工作得非常好。但是,我不知道数组的大小,大约100幅图像。我只知道每个纬度和经度之间的差异。(比如说0.00875)你知道如何使用纬度和经度这两个属性来显示类似的地图吗?