PHP Warning: Illegal string offset 'path' & 'title'

The error means the $file array does not contain the key path (or title);

Do some debugging in your code to find the reason for the error. E.g., add:

print_r( $file );

And see if it outputs an array with these keys.

It could be that some $files are empty by nature, in which case, do:

<?php foreach($files as $file) : ?>   
    <?php if ( isset( $file['path'] ) && isset( $file['title'] ) ) : ?>     
        <div class="pdf"><a href="https://stackoverflow.com/questions/42551648/<?php echo $file["path'];?>"><?php echo $file['title'];?></a></div>
    <?php endif; ?>
<?php endforeach; ?>

Browse More Popular Posts

Leave a Comment