title: Cannot use a scalar value as an array in my PHP
body: <p>I am actually just started to learn PHP and I use wordpress. I put this code but seems something wrong in it. It shows warning message : Cannot use a scalar value as an array. Can you guys help me with this. Its pretty annoying when I see the warning message on the add new product under the product data table.</p>
  
  <p>Oh, I am using PHP 7.1 now. </p>
  
  <p>I've tried to fix it using PHP checker and searching through the search engine but since I am a beginner, I couldn't find anything that can help. </p>
  
  <pre><code>/**
       * Localizes a script, only if the script has already been added.
       *
       * @since 2.1.0
       *
       * @param string $handle      Name of the script to attach data to.
       * @param string $object_name Name of the variable that will contain the data.
       * @param array  $l10n        Array of data to localize.
       * @return bool True on success, false on failure.
  */
  
      public function localize( $handle, $object_name, $l10n ) {
      if ( $handle === 'jquery' ) {
          $handle = 'jquery-core';
      }
  
      if ( is_array( $l10n ) &amp;&amp; isset( $l10n['l10n_print_after'] ) ) { // back compat, preserve the code in 'l10n_print_after' if present.
          $after = $l10n['l10n_print_after'];
          unset( $l10n['l10n_print_after'] );
      }
  
      foreach ( (array) $l10n as $key =&gt; $value ) {
          if (! is_scalar( $value ) ) {
              continue;
          }
  
          $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
      }
  
      $script = "var $object_name = " . wp_json_encode( $l10n ) . ';';
  
      if ( ! empty( $after ) ) {
          $script .= "\n$after;";
      }
  
      $data = $this-&gt;get_data( $handle, 'data' );
  
      if ( ! empty( $data ) ) {
          $script = "$data\n$script";
      }
  
      return $this-&gt;add_data( $handle, 'data', $script );
  }
  </code></pre>
  
  <p>Just want to see the warning message not showing up again. </p>
  
  <p>Thanks in advance</p>