Reputation: 8385
I am having a strange issue with the output of data for my foreach loop. The loop is not showing the data for the $image->thumbname
,$description
or $id
but the print_r($get_images);
works fine
Print_r Output:
Array ( [0] =>
Array ( [id] => 1
[description] => testing
[imagename] => test.jpg
[thumbname] => test_thumb.jpg
) )
View:
<?php if(is_array($get_images)): ?>
<? print_r($get_images); ?>
<?php foreach($get_images as $image): ?>
<img src ="<?=base_url()?>includes/uploads/gallery/thumbs/<?=$image->thumbname?>" alt="<?= $image->description?>"> <a href="deleteimage/<?=$image->id?>">Delete</a>
<?php print_r($image); ?>
<?php endforeach; ?>
<?php endif; ?>
Upvotes: 0
Views: 185
Reputation: 30170
youre using ->
to access the array contents youre supposed to use []
<?php if(is_array($get_images)): ?>
<? print_r($get_images); ?>
<?php foreach($get_images as $image): ?>
<img src ="<?=base_url()?>includes/uploads/gallery/thumbs/<?= $image['thumbname'] ?>" alt="<?= $image['description'] ?>"> <a href="deleteimage/<?= $image['id'] ?>">Delete</a>
<?php print_r($image); ?>
<?php endforeach; ?>
<?php endif; ?>
Upvotes: 2