-1

My Wordpress page (yarnhk.com) appears the following lines:

Warning: array_key_exists() expects parameter 2 to be array, string given in /home/yarnhrnm/public_html/wp-content/plugins/fusion-core/shortcodes/class-fullwidth.php on line 482

Warning: array_key_exists() expects parameter 2 to be array, string given in /home/yarnhrnm/public_html/wp-content/plugins/fusion-core/shortcodes/class-fullwidth.php on line 483

The fullwidth.php file line 482 & 483 show as follows:

if ( ( array_key_exists( 'backgroundattachment', $args ) 
   && $args['backgroundattachment'] == 'scroll' ) 
   || ( array_key_exists( 'background_attachment', $args ) 
   && $args['background_attachment'] == 'scroll' )

Any help here?

James
  • 4,644
  • 5
  • 37
  • 48
Shan Ki
  • 33
  • 1
  • 1
  • 6
  • 3
    What is the output of this: `var_dump($args);` – Tuan Anh Hoang-Vu Jun 02 '15 at 13:51
  • This page should be:http://yarnhk.com/home-3/ – Shan Ki Jun 02 '15 at 13:53
  • To tunananh, sorry that I do not quite understand your meaning.... – Shan Ki Jun 02 '15 at 13:57
  • 1
    `$args` needs to be an array. Is it an array? `array_key_exists() expects parameter 2 to be array` - it tells you right there. The chances are (the issue *is*), `$args` is not an array. put the code @tuananh gave you under the code you provided in your question and tell us what it returns – James Jun 02 '15 at 13:57
  • The error is clear enough: You have to provide an array, and AREN'T – Marc B Jun 02 '15 at 14:01
  • possible duplicate of [Warning: array\_key\_exists() expects parameter 2 to be array, boolean given](http://stackoverflow.com/questions/12747066/warning-array-key-exists-expects-parameter-2-to-be-array-boolean-given) – deceze Jun 02 '15 at 14:04

2 Answers2

0

parameter 2 to be array, string given

The error message says, that your $args is not an array but a normal string. Look for the definition of the variable (and - of course - for any accident overwriting).

You should use var_dump($args); to output the type and the value of $args.

Richard
  • 2,840
  • 3
  • 25
  • 37
  • Does it mean like this:if ( ( array_key_exists( 'backgroundattachment', var_dump($args); ) && $args['backgroundattachment'] == 'scroll' ) || ( array_key_exists( 'background_attachment', var_dump($args); ) && $args['background_attachment'] == 'scroll' ) ) – Shan Ki Jun 03 '15 at 04:18
0

Finally, I have made it with the following codes:

if( is_array($args) && ( array_key_exists( 'backgroundattachment', $args ) && $args['backgroundattachment'] == 'scroll' ) || is_array($args) && ( array_key_exists( 'background_attachment', $args ) && $args['background_attachment'] == 'scroll' )) { 
    // Something
}

Done!

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Shan Ki
  • 33
  • 1
  • 1
  • 6