PHP 5 has reached end of support and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy PHP 5
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing PHP
5 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of PHP.
\google\appengine\util\ArrayUtil
Stay organized with collections
Save and categorize content based on your preferences.
FINAL
Various PHP array related utility functions.
Methods
findByKeyOrNull
STATIC
findByKeyOrNull(array $array, mixed $key) : mixed
Find an item in an associative array by a key value, or return null if not
found.
Parameters
Name |
Description |
$array
|
array
|
$key
|
mixed
|
Returns
mixed
The value of the item in the array with the given key,
or null if not found.
findByKeyOrDefault
STATIC
findByKeyOrDefault(array $array, mixed $key, mixed $default) : mixed
Find an item in an associative array by a key value, or return default if
not found.
Parameters
Name |
Description |
$array
|
array
|
$key
|
mixed
|
$default
|
mixed
- The value to return if key is not found.
|
Returns
mixed
The value of the item in the array with the given key,
or the given default if not found.
arrayMergeIgnoreCase
STATIC
arrayMergeIgnoreCase()
Merge a number of arrays using a case insensitive comparison for the array
keys.
Throws
\google\appengine\util\InvalidArgumentException
If less than two arrays are passed to
the function, or one of the arguments is not an array.
isAssociative
STATIC
isAssociative( $arr) : boolean
Checks whether an array's keys are associative. An array's keys are
associate if they are not values 0 to count(array) - 1.
Parameters
Name |
Description |
$arr
|
array The array whos keys will be checked. |
Returns
boolean
True if the array's keys are associative. Also true in the
case of an empty array.
all
STATIC
all( $array, $predicate) : boolean
Checks whether every value in an array passes the provided predicate.
Parameters
Name |
Description |
$array
|
array The array to test. |
$predicate
|
callable A predicate which should take one argument and
return a boolean. |
Returns
boolean
Whether every value in the array passes the predicate.
allInstanceOf
STATIC
allInstanceOf( $array, $class) : boolean
Checks whether every value in an array is an instance of a class.
Parameters
Name |
Description |
$array
|
array The array to test. |
$class
|
The fully qualified class name to check every array value
with. |
Throws
\InvalidArgumentException
if no class with name $class is found.
Returns
boolean
Whether every value in the array is an instance of $class.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThis document describes several utility functions for working with PHP arrays, including searching, merging, and validating.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003efindByKeyOrNull\u003c/code\u003e and \u003ccode\u003efindByKeyOrDefault\u003c/code\u003e allow searching an associative array by key, with the ability to return either null or a default value if the key is not found.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003earrayMergeIgnoreCase\u003c/code\u003e merges multiple arrays using case-insensitive key comparison.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eisAssociative\u003c/code\u003e determines if an array's keys are associative, meaning they are not sequential numerical indexes.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eall\u003c/code\u003e and \u003ccode\u003eallInstanceOf\u003c/code\u003e provide ways to validate the contents of an array, checking if every element passes a given predicate or is an instance of a specific class.\u003c/p\u003e\n"]]],[],null,["# \\google\\appengine\\util\\ArrayUtil\n\nFINAL\n\nVarious PHP array related utility functions.\n\nMethods\n-------\n\n### findByKeyOrNull\n\n\nSTATIC\n\n`findByKeyOrNull(array `$array`, mixed `$key`) : mixed`\n\nFind an item in an associative array by a key value, or return null if not\nfound.\n\n#### Parameters\n\n#### Returns\n\n`mixed`\n\nThe value of the item in the array with the given key,\nor null if not found.\n\n### findByKeyOrDefault\n\n\nSTATIC\n\n`findByKeyOrDefault(array `$array`, mixed `$key`, mixed `$default`) : mixed`\n\nFind an item in an associative array by a key value, or return default if\nnot found.\n\n#### Parameters\n\n#### Returns\n\n`mixed`\n\nThe value of the item in the array with the given key,\nor the given default if not found.\n\n### arrayMergeIgnoreCase\n\n\nSTATIC\n\n`arrayMergeIgnoreCase() `\n\nMerge a number of arrays using a case insensitive comparison for the array\nkeys.\n\n#### Throws\n\n`\\google\\appengine\\util\\InvalidArgumentException`\n\nIf less than two arrays are passed to\nthe function, or one of the arguments is not an array.\n\n### isAssociative\n\n\nSTATIC\n\n`isAssociative( `$arr`) : boolean`\n\nChecks whether an array's keys are associative. An array's keys are\nassociate if they are not values 0 to count(array) - 1.\n\n#### Parameters\n\n#### Returns\n\n`boolean`\n\nTrue if the array's keys are associative. Also true in the\ncase of an empty array.\n\n### all\n\n\nSTATIC\n\n`all( `$array`, `$predicate`) : boolean`\n\nChecks whether every value in an array passes the provided predicate.\n\n#### Parameters\n\n#### Returns\n\n`boolean`\n\nWhether every value in the array passes the predicate.\n\n### allInstanceOf\n\n\nSTATIC\n\n`allInstanceOf( `$array`, `$class`) : boolean`\n\nChecks whether every value in an array is an instance of a class.\n\n#### Parameters\n\n#### Throws\n\n`\\InvalidArgumentException`\n\nif no class with name $class is found.\n\n#### Returns\n\n`boolean`\n\nWhether every value in the array is an instance of $class."]]