Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP array as array key [closed]

Tags:

arrays

php

Is it possible in php to make an array an array key as well?

Example:

array(
   array('sample', 'abc') => 'sample value'
);
like image 815
Aldee Avatar asked Sep 05 '12 14:09

Aldee


People also ask

Can array key be an array?

As array values can be other arrays, trees and multidimensional arrays are also possible. And : The key can either be an integer or a string. The value can be of any type.

What is array_keys () used for in PHP?

The array_keys() function returns an array containing the keys.

How do you check if a key exists in an array PHP?

PHP array_key_exists() Function The array_key_exists() function checks an array for a specified key, and returns true if the key exists and false if the key does not exist.

What is $Key in PHP?

Technical Details. Return Value: Returns the key of the array element that is currently being pointed to by the internal pointer. PHP Version: 4+


1 Answers

No, if you read the manual

An array in PHP is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more. As array values can be other arrays, trees and multidimensional arrays are also possible.

And :

The key can either be an integer or a string. The value can be of any type.

like image 139
Kasia Gogolek Avatar answered Oct 11 '22 05:10

Kasia Gogolek