0
Good afternoon, you guys! Next, I have three file fields in a table of my database, are they: File1, File2 and File3. I also have a get and a set for each of them. The point is, I wanted to run a for() and on each loop increment the get.
<?php if(isset($pedido) && $pedido->getFile1() != null): ?>
<?php for($i=0;$i<$count;$i++): ?>
<div class="list-group">
<div class="list-group-item">
<a target="_blank" href="<?php echo '/files/'.$pedido->getFile[$i](); ?>">
<i class="fa fa-file-o"></i>
<strong>
Arquivo <?php echo $i; ?>
<i class="fa fa-lock"></i>
</strong>
</a>
<br />
<p>
<?php echo $pedido->getFile[i](); ?>
</p>
</div>
</div>
<?php endfor; ?>
<?php else: ?>
that is, in each increment would getFile1(), getFile2, getFile3. Is there any way you could do that? I know that syntax [$i] there doesn’t work, it was more to exemplify.
So great is the difference between those
gets
? based on the name use would suffice.– rray
No, they are all the same, I am new in php sorry if the question is too ridiculous. As well "by the name use would suffice"?
– Caue Silvestre
But you have several functions of
getFile
all numbered ? And they’re all the same/similar ? So it means you don’t have things structured correctly and you need to refactor your code. Create a functiongetFile
that receives the number as parameter and apply only the differences there inside– Isac