phposclass

PHP Warning: implode(): Invalid arguments passed in


I am using Osclass 3.5.3. In my log file, I keep seeing the following error:

"PHP Warning: implode(): Invalid arguments passed in"

The lines in question are:

<!-- <small><?php _e("Location", 'aiclassy');?>: <cite title="<?php echo implode(', ', $location); ?>"><?php echo osc_user_city(); ?><span class="glyphicon glyphicon-map-marker"></span></cite></small><br /><br /> -->
<!-- <span class="glyphicon glyphicon-envelope"></span> <?php printf(__('%s', 'aiclassy'), osc_item_contact_email()); ?><br /> -->

The whole code is wrapped up in like this:

<div class="well">
                    <div class="row">
                      <div class="col-sm-12">            

        <!-- <small><?php _e("Location", 'aiclassy');?>: <cite title="<?php echo implode(', ', $location); ?>"><?php echo osc_user_city(); ?><span class="glyphicon glyphicon-map-marker"></span></cite></small><br /><br /> -->
        <!-- <span class="glyphicon glyphicon-envelope"></span> <?php printf(__('%s', 'aiclassy'), osc_item_contact_email()); ?><br /> -->




                <?php osc_run_hook('item_detail', osc_user() ); ?>
                <?php //voting_item_detail_user(); ?>

                      </div>


                </div>

                </div>

How do I resolvethis...any suggestions, please? Thank you, all.


Solution

  • If you are unsure about if the value for $location is an array or a string you could decide it right away when echoing the value.

    <?php echo is_array($location) ? implode(', ', $location) : $location; ?>
    

    This is meant as a replacement for the current

    <?php echo implode(', ', $location); ?>