Title: PHP E_WARNING (#2): Undefined array key 0 : WPML_Plugin.php (587)
Last modified: November 6, 2024

---

# PHP E_WARNING (#2): Undefined array key 0 : WPML_Plugin.php (587)

 *  Resolved [jibbius](https://wordpress.org/support/users/jibbius/)
 * (@jibbius)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/php-e_warning-2-undefined-array-key-0-wpml_plugin-php-587/)
 * I am getting the following warning, after updating to v1.13.1:
 *     ```wp-block-code
       PHP E_WARNING (#2): Undefined array key 0wp-content/plugins/wp-mail-logging/src/WPML_Plugin.php (587)
       ```
   
 * The offending code is trying to read from an array, but is incorrectly using 
   a numeric index.
   The array’s keys are set to values such as **From** and **CC**.
 *     ```wp-block-code
       var_dump($mail_headers) ...array ('From' => 'From: Sales@test.com','Cc' => 'Cc: ','Bcc' => 'Bcc: Test@test.com','Content-type' => 'Content-type: text/html; charset=UTF-8',)
       ```
   
 * I think the fix should be as follows:
 *     ```wp-block-code
       // BEFORE:        for ( $ctr = 0; $ctr < count( $mail_headers ); $ctr++ ) {            $header_arr = explode( ":", $mail_headers[ $ctr ] );            // If Content-Type header is already set, don't add it again.            if ( ! empty( $header_arr[0] ) && strtolower( $header_arr[0] ) === 'content-type' ) {                $should_force_add_content_type = false;            }        }
       ```
   
 *     ```wp-block-code
       // AFTER:        foreach (  $mail_headers as $mail_header ) {            $header_arr = explode( ":", $mail_header );            // If Content-Type header is already set, don't add it again.            if ( ! empty( $header_arr[0] ) && strtolower( $header_arr[0] ) === 'content-type' ) {                $should_force_add_content_type = false;                break;            }        }
       ```
   
    -  This topic was modified 1 year, 7 months ago by [jibbius](https://wordpress.org/support/users/jibbius/).

Viewing 1 replies (of 1 total)

 *  Plugin Author [Michael](https://wordpress.org/support/users/donmhico/)
 * (@donmhico)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/php-e_warning-2-undefined-array-key-0-wpml_plugin-php-587/#post-18121651)
 * Hello [@jibbius](https://wordpress.org/support/users/jibbius/),
   Thank you for
   bringing this up and we definitely appreciate that you provide the fix. We’ll
   definitely include this in the next release!

Viewing 1 replies (of 1 total)

The topic ‘PHP E_WARNING (#2): Undefined array key 0 : WPML_Plugin.php (587)’ is
closed to new replies.

 * ![](https://ps.w.org/wp-mail-logging/assets/icon-256x256.jpg?rev=2562296)
 * [WP Mail Logging](https://wordpress.org/plugins/wp-mail-logging/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-logging/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-logging/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-logging/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-logging/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-logging/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/donmhico/)
 * Last activity: [1 year, 7 months ago](https://wordpress.org/support/topic/php-e_warning-2-undefined-array-key-0-wpml_plugin-php-587/#post-18121651)
 * Status: resolved