0

I recently updated to PHP 7.2 and now I get an error on the front end of my website. The error states:

Warning: A non-numeric value encountered on line 3378

The code on that line is below. Can someone help me correct this please?

$words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
user3612498
  • 147
  • 1
  • 4
  • 14
  • 1
    what's the value of `$num_words`? Looks like it's a string (or NaN). This error seems to be new in php 7: https://3v4l.org/FObqq – Jeff Feb 01 '19 at 00:13

1 Answers1

0

This warning is new as of 7.1.:
http://php.net/manual/en/migration71.other-changes.php
when trying use math operators with a string as shown in this quick test: https://3v4l.org/FObqq

(a bool seems to be fine instead)

After answering I also found the dupe here: Warning: A non-numeric value encountered

Jeff
  • 6,895
  • 1
  • 15
  • 33