Title: PHP Notice: Undefined offset: 1
Last modified: March 21, 2019

---

# PHP Notice: Undefined offset: 1

 *  Resolved [ceitechllc](https://wordpress.org/support/users/ceitechllc/)
 * (@ceitechllc)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/php-notice-undefined-offset-1-3/)
 * Hello,
 * I am getting (on average) roughly 42 lines of PHP Notice logs added to our ‘*.
   error.log’ file every time Autoptimzize attempts to do something. The error log
   dump looks as follows, with our local directory removed:
 * > [21-Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390
   >  [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390 [21-
   > Mar-2019 16:12:17 UTC] PHP Notice: Undefined offset: 1 in /home/***/public_html/
   > wp-content/plugins/autoptimize/classes/autoptimizeExtra.php on line 390
 * Within “autoptimizeExtra.php”, on line 389:
 * > $indiv_srcset_parts = explode( ‘ ‘, trim( $indiv_srcset ) );
 * I can see the empty value, but as this is apart of your core code, I’d like your
   help for addressing this error. The error dump files are getting excessively 
   large as this block of ~42 lines gets added every couple of hours.
 * The entire code block in “autoptimizeExtra.php”, on lines 376 thru 400:
 * >  // extract img tags.
   >  if ( preg_match_all( ‘#<img[^>]*src[^>]*>#Usmi’, $in,
   > $matches ) ) { foreach ( $matches[0] as $tag ) { $orig_tag = $tag; $imgopt_w
   > = ”; $imgopt_h = ”;
   >  // first do (data-)srcsets.
   >  if ( preg_match_all( ‘#srcset=(“|\’)(.*)(“|\’)#
   > Usmi’, $tag, $allsrcsets, PREG_SET_ORDER ) ) { foreach ( $allsrcsets as $srcset){
   > $srcset = $srcset[2]; $srcsets = explode( ‘,’, $srcset ); foreach ( $srcsets
   > as $indiv_srcset ) { $indiv_srcset_parts = explode( ‘ ‘, trim( $indiv_srcset));
   > if ( $indiv_srcset_parts[1] && rtrim( $indiv_srcset_parts[1], ‘w’ ) !== $indiv_srcset_parts[
   > 1] ) { $imgopt_w = rtrim( $indiv_srcset_parts[1], ‘w’ ); } if ( $this->can_optimize_image(
   > $indiv_srcset_parts[0] ) ) { $imgopt_url = $this->build_imgopt_url( $indiv_srcset_parts[
   > 0], $imgopt_w, ” ); $tag = str_replace( $indiv_srcset_parts[0], $imgopt_url,
   > $tag ); $to_replace[ $orig_tag ] = $tag; } } } }
 * **EDIT: Accidently a word lol
    -  This topic was modified 7 years, 1 month ago by [ceitechllc](https://wordpress.org/support/users/ceitechllc/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-notice-undefined-offset-1-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Thread Starter [ceitechllc](https://wordpress.org/support/users/ceitechllc/)
 * (@ceitechllc)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/php-notice-undefined-offset-1-3/#post-11340479)
 * Additional Information:
 * Autoptimize version – 2.4.4
    WP version – 5.1 PHP version – 7.1.27
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/php-notice-undefined-offset-1-3/#post-11340606)
 * This _should_ be fixed in AO25 which is in beta now, would be great if you could
   [download that and take it out for a spin](https://github.com/futtta/autoptimize/archive/beta.zip)?
   🙂
 * frank
 *  Thread Starter [ceitechllc](https://wordpress.org/support/users/ceitechllc/)
 * (@ceitechllc)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/php-notice-undefined-offset-1-3/#post-11340618)
 * I’ll download it and give it a test later today.
 * Thank you for the quick response, frank
 *  Thread Starter [ceitechllc](https://wordpress.org/support/users/ceitechllc/)
 * (@ceitechllc)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/php-notice-undefined-offset-1-3/#post-11343841)
 * I was able to deploy the beta code, and the errors above seem to have been corrected,
   though I am receiving a new log dump.
 * It’s still roughly the same about of lines. The PHP notice is as follows:
 * >  …
   >  [22-Mar-2019 13:14:24 UTC] PHP Notice: Undefined offset: 1 in /home/***/
   > public_html/wp-content/plugins/autoptimize-beta/classes/autoptimizeImages.php
   > on line 508 [22-Mar-2019 13:14:24 UTC] PHP Notice: Undefined offset: 1 in /
   > home/***/public_html/wp-content/plugins/autoptimize-beta/classes/autoptimizeImages.
   > php on line 508 [22-Mar-2019 13:14:24 UTC] PHP Notice: Undefined offset: 1 
   > in /home/***/public_html/wp-content/plugins/autoptimize-beta/classes/autoptimizeImages.
   > php on line 508 [22-Mar-2019 13:14:24 UTC] PHP Notice: Undefined offset: 1 
   > in /home/***/public_html/wp-content/plugins/autoptimize-beta/classes/autoptimizeImages.
   > php on line 508 …
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/php-notice-undefined-offset-1-3/#post-11344298)
 * same error, other file because all image optimization logic was moved to autoptimizeImages.
   php 🙂
 * I’ll come with a fix later today!
 * But question: as far as I can tell you’re not using the image optimization in
   AO? Or are these notices the reason why you disabled it?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/php-notice-undefined-offset-1-3/#post-11344534)
 * OK, [this commit](https://github.com/futtta/autoptimize/commit/150e3a328b398cfee853fd12ea29f36286162d56)
   should fix that notice, can you test?
 * re. have AO img opt active; it’s possible you have it active, but as you’re already
   using jetpack to do the same, the AO one just let’s things be 🙂

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

The topic ‘PHP Notice: Undefined offset: 1’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

## Tags

 * [notice](https://wordpress.org/support/topic-tag/notice/)
 * [offset](https://wordpress.org/support/topic-tag/offset/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [undefined](https://wordpress.org/support/topic-tag/undefined/)

 * 6 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/php-notice-undefined-offset-1-3/#post-11344534)
 * Status: resolved