Shift with red gradient lettering

Array Functions

PHP

Adopt array functions like array_key_first, array_key_last, and is_countable, as well as streamline code to use other native PHP array functions.

Before

reset($items)
$firstKey = key($items);
end($items);
$lastKey = key($items);
 
is_array($foo) || $foo instanceof Countable;
 
$keys = array_keys($values);
$exists = in_array($packageName, $keys, true);
 
array_search("foo", $array) !== false;
 
foreach ($values as $key => $value) {
$items[$key] = null;
}

After

$firstKey = array_key_first($items);
$lastKey = array_key_last($items);
 
is_countable($foo);
 
$exists = array_key_exists($packageName, $values);
 
in_array("foo", $array);
 
foreach (array_keys($values) as $key) {
$items[$key] = null;
}

← Back to the Workbench Tasks

Sign in with any of the following services to connect Shift with your Laravel project.


Don't use one of these services?

Temporarily push your project to a free, private repository on one of these cloud-based services or upgrade your project locally with Shift for Docker.