Mar 27

Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /your-sitepath/wp-admin/includes/media.php on line 736

This problems stems from line 736 as stated above. The simple fix is to make sure the first argument is a string, to do this we will rap it in double quotes.

Change line 736 from:

if(!array_key_exists($checked, $alignments))

To

if(!array_key_exists("$checked", $alignments))

Don’t see the difference? Just add double quotes around the first argument $checked. Make sure they are not single quotes.

One Response to “Fixing the array_key_exists Warning in WordPress media.php”

  1. Levi Putna says:

    This fix also works with the warning in wp-includes/category-template.php on line 176

    Change:

    if(array_key_exists($category, $categories))

    Line 176 To

    if(array_key_exists(“$category”, $categories))

Leave a Reply