Title: PHP error &#8220;Array to string conversion&#8221;
Last modified: March 2, 2024

---

# PHP error “Array to string conversion”

 *  Resolved [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * (@manujacquet)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/)
 * **My configuration WP:**
    - **– Version of WordPress :** 6.4.3
    - **– Version of PHP/MySQL :** 8.1.16 / 5.7.23
    - **–Version of event manager :** Events Manager (6.4.6.4)
 * My problem :
 * In the file errorlog-php, I’ve got some recursive errors (one every about 5 minutes):
 * _[27-Feb-2024 07:23:24 UTC] PHP Warning: Array to string conversion in /srv/data/
   web/vhosts/…/htdocs/wp-content/plugins/events-manager/classes/em-calendar.php
   on line 494_
 * I’ve seen in this support forum, some people have the same error.

Viewing 15 replies - 1 through 15 (of 15 total)

 *  [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17468653)
 * To figure out what’s causing this error you need to temporarily modify wp-content/
   plugins/events-manager/classes/em-calendar.php
 * Make a backup copy of em-calendar.php and then change line 494 from this:
 *     ```wp-block-code
       if( is_array($value) ) $value = implode(',', $value);
       ```
   
 * To this:
 *     ```wp-block-code
       if ( is_array( $value ) ) {
         foreach ( $value as $el ) {
           if (is_array($el)) {
             error_log('$arg[' . $name . '] contains an array element. The value is:' . print_r( $value, true ) );
             break;
           }
         }
         $value = implode(',', $value);
       }
       ```
   
 * Then post the new error output here.
 *  Thread Starter [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * (@manujacquet)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17468759)
 * Thanks for your response. I changed the line and here the new error output:
 * [02-Mar-2024 16:12:08 UTC] $arg[panels_info] contains an array element. The value
   is:Array ( [class] => EM_Widget_Calendar [grid] => 4 [cell] => 1 [id] => 11 [
   widget_id] => 194e29ab-e739-4f87-aa57-43139a341c71 [style] => Array ( [background_image_attachment]
   => [background_display] => tile ) [cell_index] => 0 [widget_index] => 11 )
 *  [02-Mar-2024 16:12:08 UTC] PHP Warning: Array to string conversion in /srv/data/……../
   wp-content/plugins/events-manager/classes/em-calendar.php on line 501
 *  [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17468990)
 * The function EM_Calendar::output is getting called with a $args array and it 
   has an entry $args[‘style’] which is equal to array([background_image_attachment
   => “”, background_display=> “tile”)
 * This doesn’t seem to be coming from the Events Manager plugin. Are you using 
   Events Manager Pro? Looks like this error comes when displaying the Events Calendar
   Widget. Are then any url parameters when dispaying the page? Is there some way
   to specify the background style when adding widgets in your theme?
 * You could try the following code snippet to fix this problem:
 *     ```wp-block-code
       add_filter('em_widget_calendar_get_args', function( $args ) {
           if ( is_array( $args ) && array_key_exists( 'style', $args ) {
               unset( $args['style'] );
           }
           return $args;
       });
       ```
   
 * You can use the [Code Snippets](https://wordpress.org/plugins/code-snippets/)
   plugin to add this code snippet.
 *  Thread Starter [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * (@manujacquet)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17469803)
 * Hi,
 * I searched for css code that I had added and actually, yes, I added that code
   to my stylesheet :
 *     ```wp-block-code
       .tribe-events-widget .tribe-events-widget-events-list__event-row--featured .tribe-events-widget-events-list__event-date-tag-datetime::after
       {
       background-color: #f0ab06 !important;
       }
   
   
       .tribe-events-widget .tribe-events-widget-events-list__view-more-link:visited
       {
       color: #685800 !important;
       }
       ```
   
 * I deleted it but it didnt change anything.
 *  I tried to add your code with the widget code snippets but that’s no effect.
 * And I don’t use the pro version.
 *  [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470049)
 * Try modifying the code snippet to this:
 *     ```wp-block-code
       add_filter('em_calendar_get_args', function( $args ) {
           if ( is_array( $args ) && array_key_exists( 'style', $args ) {
               unset( $args['style'] );
           }
           return $args;
       });
       ```
   
 *  Thread Starter [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * (@manujacquet)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470323)
 * I tried but not effect.
 * Even I added the missing parenthesis after `$args )` to fix the syntax error.
 *  [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470333)
 * There was no syntax error in my code snippet:
 * ![](https://i0.wp.com/www.ourfamilybios.com/wp-content/uploads/2024/03/Screenshot-
   2024-03-03-152728.png?ssl=1)
 * You must have made a mistake when copying and pasting the code snippet. Make 
   sure you copy the code snippet from the code block in this thread (not from the
   email).
 *  Thread Starter [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * (@manujacquet)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470350)
 * **Snippet automatically deactivated due to an error on line 3:**
 * > Syntax error, unexpected token “unset”.
 * The correction in bold in that code :
 *     ```wp-block-code
       add_filter('em_calendar_get_args', function( $args ) {
           if ( is_array( $args ) && array_key_exists( 'style', $args ) ) {
               unset( $args['style'] );
           }
           return $args;
       });
       ```
   
 *  [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470355)
 * The error must have occurred when you copied the code snippet. I copied and pasted
   my code snippet and I didn’t get any syntax error.
 *  Thread Starter [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * (@manujacquet)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470359)
 * But in your condition, it miss an ” ) ” at the end :
 *     ```wp-block-code
       if ( is_array( $args ) && array_key_exists( 'style', $args )
       ```
   
 *  Thread Starter [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * (@manujacquet)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470363)
 * Otherwise, I assure you that I copied your code correctly without any errors.
   The widget does show a syntax error, which I fixed by adding a parenthesis at
   the end of the ‘if’ condition line.
 *  [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470364)
 * You’re correct, there was a missing paren in my code snippet. Hopefully, the 
   plugin author will add a check to prevent the PHP Warning that you are reporting
   in a future release.
    -  This reply was modified 2 years, 1 month ago by [joneiseman](https://wordpress.org/support/users/joneiseman/).
 *  Thread Starter [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * (@manujacquet)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470369)
 * thank you for taking time. I will continue my research. If someone have an other
   idea ..
 *  [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470375)
 * Make sure you activated the code snippet (in the Code Snippets plugin).
 *  Thread Starter [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * (@manujacquet)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470392)
 * yes, it was 😉

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘PHP error “Array to string conversion”’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=1039078)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [PHP Warning](https://wordpress.org/support/topic-tag/php-warning/)

 * 15 replies
 * 2 participants
 * Last reply from: [manujacquet](https://wordpress.org/support/users/manujacquet/)
 * Last activity: [2 years, 1 month ago](https://wordpress.org/support/topic/php-error-array-to-string-conversion-3/#post-17470392)
 * Status: resolved