Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

array_flip_by_value_key()

Description

Flip array keys to use one of the keys of the values it contains. All elements (ie values) of the array must contain
the key (ie. they are arrays). Helper function to greatly increase search performance on huge PHP arrays.
Normal use is: array_flip_by_value_key($huge_array, 'ref');


IMPORTANT: make sure that for the key you intend to use all elements will have a unique value set.

Example: Result after calling array_flip_by_value_key($nodes, 'ref');
[20382] => Array
(
[ref] => 20382
[name] => Example node
[parent] => 20381
)

Parameters

ColumnTypeDefaultDescription
$a array
$k string A values' key to use as an index/key in the main array, ideally an integer

Return

array

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 28th November 2024 15:15 Europe/London time.