I have the below code on my page and it’s working when there is any data in the $getbanking
variable. But if $getbanking
is empty then I am getting the below error
Warning : Invalid argument supplied for foreach() in
I have to run the below code if there $getbanking
is empty at least once. So that it will display the upload option to the user.
<?php
$getbanking = unserialize($info['banking_details']);
$i=1;
foreach ($getbanking as $bankdoc => $b) { ?>
<div class="col-xl-3 col-lg-3 col-md-3 col-sm-12 col-xs-12">
<div class="documentUploadWrap">
<label>Bank <?php echo $i;?></label>
<div class="upload_doc <?php if(!empty($b)){ echo " imgext uploaded ";} ?>">
<input type="hidden" name="banking[<?php echo $bankdoc;?>]" value="<?php echo $b;?>">
<input type="file" name="banking[<?php echo $bankdoc;?>]" class="fileupload noofbank" accept="image/png, image/jpeg, application/pdf, .doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document">
<div class="uploadInfo">
<div class="upload_icon"></div>
<p>Drop your image here, or <span>browse</span></p>
<span>Supports: JPEG, PNG, DOC, PDF</span>
</div>
<div class="previewFile">
<a href="uploads/<?php echo $b; ?>" target="_blank">
<div class="previewFileIcon text-center"></div>
</a>
<p class="fileNamePreview"><?php echo $b; ?></p>
</div>
<?php if($i>=2){?>
<div class="close-box close-box-bank"><img src="assets/images/x-circle.svg"></div>
<?php }?>
</div>
</div>
</div>
<?php $i++; } ?>