Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

The warning means the first argument passed to PHP’s extract() function is not an array. Find the exact value supplied to the call, then fix the code that produced it. Use an empty-array fallback only when missing data is genuinely valid; otherwise, handle the failure or correct the function, query, or array key that returned the wrong value.

What the warning means

extract() takes an array and creates variables from its keys. Its current signature is extract(array &$array, int $flags = EXTR_OVERWRITE, string $prefix = ""): int (PHP manual: extract()). For example, extract(['title' => 'Welcome']) creates a $title variable in the current scope.

If the first argument is null, false, a string, a number, an object, or an undefined variable, it is not an array and cannot be extracted. The exact diagnostic wording varies by PHP version: older versions commonly say “expects parameter 1 to be an array,” while newer versions may describe an argument type mismatch. The underlying problem is the same.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Numeric keys are a separate issue. A numeric array is still an array, but its keys do not ordinarily become useful variable names. PHP documents prefix-related flags for extracting values from numeric keys; for most application data, an associative array is clearer.

#1 Best Overall
Sale
LAPGEAR Home Office Pro Lap Desk - Black Carbon, Fits 15.6” Laptops
  • Spacious Design: Measuring 21.1" wide and 14.1" deep, our lap desk comfortably fits most laptops up to 15.6". Extra room for accessories ensures convenience.
  • Enhanced Functionality: Packed with handy features, including a 5x9" precision tracking mouse pad and a built-in phone slot for seamless work or video calls. Plus, enjoy ergonomic support with the integrated cushioned wrist rest.
  • Cool Comfort: Enjoy a stable surface with our lap desk's dual bolster cushion, designed for comfort and airflow, keeping your lap cool during extended use.
  • Durable Surface: Work with confidence on our lap desk's solid surface, featuring a sleek black carbon color, ensuring optimal air circulation to prevent your laptop from overheating.
  • On-the-Go Convenience: With an integrated handle and lightweight design (2.8 lbs), our lap desk is portable for travel or moving around the house, offering flexibility in any space.

Find the value passed to extract()

Locate the call named in the warning, such as extract($data) or extract($config['template']). Inspect the actual argument immediately before the call—not just the variable you expected to contain an array.

$data = get_template_data();

var_dump($data);
exit;

extract($data);

For a quick type check, use gettype(), which is available in older PHP versions too. In current PHP, get_debug_type() can provide a more specific type name.

$data = load_view_data();

if (!is_array($data)) {
    die('load_view_data() returned ' . gettype($data));
}

extract($data, EXTR_SKIP);

Remove the temporary exit or diagnostic output after finding the cause. If the call contains an expression, assign that expression to a temporary variable first so you can inspect its value and type.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a fix based on what the data means

Situation What to do
No data is a valid outcome Normalize it to an empty array, then confirm the template can work without those values.
Data is required Raise or handle an error rather than silently substituting an empty array.
A function returns inconsistent types Correct its return contract and handle expected failure explicitly.
A database operation failed or found no row Check the query and fetch result before extracting it; treat failure and “no row” appropriately for the specific API.
You have an object Use its properties or an explicit conversion method, rather than assuming it is an array.
You need only a few values Assign those values explicitly instead of importing every key into local variables.

When an empty array is a valid fallback

If the data is optional—for example, a template can render without optional view variables—you can normalize a missing value before extraction:

$data = get_optional_view_data();

if (!is_array($data)) {
    $data = [];
}

extract($data, EXTR_SKIP);

For a value that may only be null, the shorter form is extract($data ?? [], EXTR_SKIP);. This is a guard, not a universal repair. It can conceal a failed query or a broken function, and the template may still warn later if it expects variables that were never supplied.

When the data is required

Fail clearly at the point where the expected type is known. This makes the source of the bad value easier to trace than a warning later in a template.

$data = get_required_view_data();

if (!is_array($data)) {
    throw new UnexpectedValueException(
        'Expected view data to be an array; got ' . gettype($data)
    );
}

extract($data, EXTR_SKIP);

In modern code that you control, declare an array return type when the function genuinely guarantees one:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function buildViewData(): array
{
    return [
        'title' => 'Example'
    ];
}

A return type makes an invalid return fail at the function boundary. In legacy code, add checks where data crosses a boundary and tighten contracts gradually.

Rank #2
OLIXIS Small Computer Desk, 31 Inch Gaming Desks for Home Office
  • Clean & Contemporary Design: You'll receive a side bag in either gray or black, chosen at random. Our desk blends seamlessly with any decor style. Its refined look enhances your space without clashing, making it a tasteful addition to your home office or bedroom
  • Spacious & Sturdy Surface: Enjoy ample space on this work desk (available in 6 sizes from 31" to 63") for multiple monitors and essentials. The reinforced structure with sturdy steel tubes ensures reliable support for intensive work or long gaming sessions
  • Versatile for Multiple Uses: This simple desk seamlessly serves as a large office desk, a small compact computer desk, a gaming table, or a student desk. It's the perfect work-from-home solution that adapts to your lifestyle, fitting effortlessly into bedrooms or small spaces
  • Integrated Side Storage Bag: Stay organized with the added convenience of a reversible side pocket. This unique storage feature can be mounted on either side of the desk to hold your pens, notebooks, or chargers, keeping your work table tidy and efficient
  • Quick & Easy Assembly: Get your new pc desk ready in a few minutes. Its simple structure, clear instructions, and all provided tools make setup straightforward, so you can quickly enjoy your new bedroom desk or home office setup without hassle

Common causes and specific repairs

1. An undefined or null variable

A variable may never have been set on one branch of the code:

extract($viewData); // $viewData was not assigned

Initialize it only if an empty result is a legitimate state:

$viewData = [];
extract($viewData, EXTR_SKIP);

If the view data is mandatory, check that it was prepared and report the failure instead of allowing a blank render:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
if (!isset($viewData) || !is_array($viewData)) {
    throw new RuntimeException('View data was not prepared correctly.');
}

extract($viewData, EXTR_SKIP);

2. A function returned null or false

Application functions and older APIs may signal different outcomes with null, false, or an exception. Do not assume every failed call returns the same value. Inspect the function’s documented contract or implementation.

$data = getUserData($id);

if ($data === false) {
    // Handle the lookup failure or expected “not found” state.
    $data = [];
}

if (!is_array($data)) {
    throw new UnexpectedValueException('User data must be an array.');
}

extract($data, EXTR_SKIP);

If the function should always return an array, fix that contract rather than converting every unexpected value into an empty result. If failure is meaningful, represent and handle it explicitly.

3. A database query or fetch did not produce a row array

A legacy pattern may pass a fetch result straight to extract():

$row = mysqli_fetch_assoc($result);
extract($row);

First check whether the query succeeded, then inspect the fetch result. A failed query, a result with no matching row, or the wrong result variable can all leave you without the row array the code expects. Return values differ among database APIs and fetch functions, so check the documentation for the function in use rather than assuming one universal failure value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
$result = mysqli_query($connection, $sql);

if ($result === false) {
    throw new RuntimeException(mysqli_error($connection));
}

$row = mysqli_fetch_assoc($result);

if ($row === null || $row === false) {
    // Handle “no row” according to the application’s requirements.
    $row = [];
}

extract($row, EXTR_SKIP);

Use the empty array here only if no row is an acceptable state. If a row is required, report or handle “not found” instead. A database query failure should not be mistaken for an ordinary empty result.

Rank #3
Sale
ErGear 48 X 24 Inch Height Adjustable Electric Standing Desk, Black
  • Electric Height Adjustable Standing Desk for Comfortable Work - Switch effortlessly between sitting and standing with this electric standing desk. The smooth height adjustment from 28.35" to 46.46" helps promote a more comfortable working posture and keeps your energy flowing throughout the workday. Ideal for home offices, gaming setups, and productivity workspaces.
  • Powerful Motor with Memory Presets - Equipped with a quiet, powerful lift motor, this sit stand desk allows seamless adjustments at the touch of a button. Save up to 4 preferred height settings so you can instantly return to your perfect working position every time.
  • Exceptional Stability Steel Frame - Built with a heavy-duty alloy steel frame and aerospace-grade lifting columns, this adjustable desk remains stable even at maximum height. Tested for 100,000 lift cycles, it delivers long-lasting durability for daily work, studying, or gaming.
  • Easy Assembly & Low-VOC Materials - Designed with low-VOC materials to help reduce indoor emissions and create a healthier workspace. With simplified assembly and included tools, you can set up your new adjustable standing desk workstation quickly and start working comfortably.

4. A configuration key is missing or contains null

In extract($config['template']), the outer value may be an array while the selected template value is absent or not an array. For optional template data:

$templateData = $config['template'] ?? [];
extract($templateData, EXTR_SKIP);

For required configuration, validate both the key and its type:

if (
    !array_key_exists('template', $config) ||
    !is_array($config['template'])
) {
    throw new UnexpectedValueException(
        'config["template"] must be an array'
    );
}

extract($config['template'], EXTR_SKIP);

isset($array['key']) is false if the key is absent or its value is null. array_key_exists() distinguishes those cases, which matters if a present-but-null value has meaning. See the PHP array documentation.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. The expression selects a scalar from a nested array

Check the final part of the expression. An outer array does not guarantee that a nested value is also an array:

$data = [
    'user' => [
        'name' => 'Ava'
    ]
];

extract($data['user']['name']); // 'Ava' is a string, not an array

If you intended to extract the user’s fields, pass the nested array:

extract($data['user'], EXTR_SKIP);

Often it is clearer to preserve the structure and read the value directly:

$user = $data['user'];
echo $user['name'];

6. The value is an object

An object is not an array. If it has an explicit conversion method, use that when its output is intended for the template:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
$user = getUser();
extract($user->toArray(), EXTR_SKIP);

A cast such as (array) $user changes the type but is not a general substitute: ordinary casting exposes public properties and can represent protected or private properties with special keys. Prefer direct property access or a deliberate toArray() method whose output you understand. The PHP extract() reference discusses object casting and extraction examples.

Rank #4
Sale
BUYIFY 23.4" Foldable Lap Desk Bed Table with Cup Holder Tray Black
  • 1 case of 41 Packs, 41 Count Total
  • PERFECT FOLDABLE DESIGN: 23.43"(L)x15.75"(W)x9.25"(H).This laptop bed desk is designed to be foldable, allowing you to easily open the table legs for use without any assembly. When not in use, simply fold it in half for compact storage, saving space in your room.
  • CONVENIENT CUP HOLDER AND TABLET SLOT: Features a built-in cup holder to securely hold your drink and a stand groove to keep your tablet, or phone upright, making it easy to enjoy your favorite shows or work hands-free.
  • MULTI-FUNCTIONAL: This laptop table is designed for versatility.Ideal for various activities like working, studying, reading, eating, or watching movies. Perfect for use on the bed, sofa, floor, balcony, or even outdoors. Can be used as a laptop desk, dining tray, mini writing desk, or picnic table.
  • ERGONOMIC AND SPACIOUS DESIGN: The desk dimensions are designed for comfort, providing ample space for laptops, books, or meals. Enjoy an ergonomic setup whether you’re sitting cross-legged on the sofa or lying comfortably in bed.

7. Parsed query data was not captured

Older code may call parse_str() without its result parameter and then expect a variable named $data to exist:

parse_str($query);
extract($data);

Capture the parsed output explicitly:

parse_str($query, $data);
extract($data, EXTR_SKIP);

The second parameter is the result array. Omitting it was deprecated as of PHP 7.2 and is not permitted as of PHP 8.0. See the PHP parse_str() reference.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Prevent collisions and avoid unsafe extraction

The default extraction mode is EXTR_OVERWRITE, which can overwrite variables already present in the current scope. Use EXTR_SKIP when existing variables should win:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
extract($data, EXTR_SKIP);

Or prefix imported names to make their origin clearer:

extract($data, EXTR_PREFIX_ALL, 'view');
echo $view_title;

These flags address naming collisions; they do not validate the array or make untrusted input safe. PHP specifically warns against using extract() on user-controlled values such as $_GET and $_FILES. Do not write extract($_GET), extract($_POST), or extract($_FILES). Map only the fields you expect and validate their types:

$title = isset($_POST['title']) && is_string($_POST['title'])
    ? $_POST['title']
    : '';

For a handful of values, explicit assignments are usually easier to audit and less prone to accidental overwrites:

$title = $data['title'] ?? '';
$description = $data['description'] ?? '';

echo $title;
echo $description;

extract() creates variables in the current scope. Calling it inside a function does not create variables in the caller’s scope. Also use EXTR_REFS only when you deliberately want extracted variables to reference and modify the original array values.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Debugging checklist

  • Find the exact extract() call and inspect its complete first-argument expression.
  • Split inline calls or nested-key expressions into a temporary variable.
  • Check the runtime type and value with var_dump() and is_array().
  • Look for an uninitialized variable, a null or false return, or a missing array key.
  • Check whether a database query failed or a fetch returned no row; consult that API’s return-value documentation.
  • Verify that the final nested value is an array, not a string or other scalar.
  • If the value is an object, choose explicit property access or an intentional conversion.
  • Decide whether missing data is valid; do not use [] to hide a required-data failure.
  • Use EXTR_SKIP or a prefix if extraction could overwrite local variables.
  • Never pass untrusted request data directly to extract().

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.