how to create an associative array in php

Solutions on MaxInterview for how to create an associative array in php by the best coders in the world

showing results for - "how to create an associative array in php"
Bautista
27 May 2019
1<?php 
2/* 
3There are 3 Types of array in php  
41. Indexed arrays - Arrays with a numeric index
52. Associative arrays - Arrays with named keys
63. Multidimensional arrays - Arrays containing one or more arrays
7
8This is the second one - Associative arrays
9*/
10
11$age = array("Samy"=>"35", "Naveen"=>"37", "Amit"=>"43");
12echo "Mr.Samy is " . $age['Samy'] . " years old.";
13
14?>
Michela
08 Aug 2016
1<?php
2	$associativeArray = [
3        "carOne" => "BMW",
4        "carTwo" => "VW",
5        "carThree" => "Mercedes"
6    ];
7    
8    echo $associativeArray["carTwo"] . " Is a german brand";
9?>
Inigo
28 Aug 2016
1<?php 
2/* 
3There are 3 Types of array in php  
41. Indexed arrays - Arrays with a numeric index
52. Associative arrays - Arrays with named keys
63. Multidimensional arrays - Arrays containing one or more arrays
7
8This is the second one - Associative arrays
9*/
10
11$age = array("Samy"=>"35", "Naveen"=>"37", "Amit"=>"43");
12echo "Mr.Samy is " . $age['Peter'] . " years old.";
13
14?>
Agustina
24 Sep 2017
1<?php 
2  /*
3  there are three type of array
4  	1 - Indexed array
5  */
6 	$a = array('a','b','c');
7	$b = ['a','b','c'];
8	/*
9    2 - Associative array
10    */
11	$c = array(
12    	'keyOne'=>'valueOne',
13      	'keyTwo'=>'valueTwo'
14    );
15	$d = [
16      'keyOne'=>'valueOne',
17      'keyTwo'=>'valueTwo'
18    ];
19/*
20    3 - Multidimensional  array
21    */
22	$c = array(
23    	'keyOne'=>array('a','b','c'),
24      	'keyTwo'=>array('a'=>'1','b'=>'2')
25    );
26	$d = [
27      'keyOne'=>['a','b','c'],
28      	'keyTwo'=>['a'=>'1','b'=>'2']
29    ];
30  ?>
Erica
06 Sep 2019
1<?php
2	$array = [
3		'key1' => 'foo',
4  		'key2' => 'bar',
5	];
6	extract($array);
7	
8	echo $key1; //print foo
9	echo $key2; //print bar
10?>
Renata
06 Jul 2017
1<?php
2$arr = array('fruit' => 'mango', 'vegetable' => 'tomato', 'thing' => 'bag');
3echo $arr['fruit'];
4/*OUTPUT
5mango*/
6?>
7
queries leading to this page
associative array phpphp associative array by keyassotiative arrays phpwhat is set associative array 28 29 in phparray of associative arrays phpphp create an associative arrayphp numeric arrayphp create array of associative arraysassociative arraysassign value to array phpassoactive array phpphp associative array keysphp associative arayphp sub assoc array get foreach an assoc array in html phpwhat is an associative array phpassociative array inside array phparr 3d 5b 5d 5b 5d phpinitialize associative array phpdisplay associative array in phpassign value associative array phpcreate assosiative array phpphp build an associative arrayphp number arraywhich of the following array represents an array with a numeric index 3fdeclaring associative arrays in phphow to make a associative array in phpphp associative array keyphp associative array typephp is in array assocassocitiva array phpphp access elements in an associative arrayassociative array functions in phpassotive array phpaccessing elements in associative arrays phparray in array associative phpassign associative array phpuseful associative array in phpin array for associative array in phpprint and associative array phpphp associative array baluesphp associative array value as keywhat is an element in associative arrayphp in array in associative arrayphp where on associative arrauhow to print associative array in php using for loopphp associative array by valueassociative demo array in phpin php 2c how do you declare an associative array 3fphp arrayt associativofor associative array phpphp arrays with keysphp get arrayhow to access an element of an associative array in phpstore in assocative array in phpin array associative phpcreate associative array in php in forloopclass as associative array in phpphp define assosicative arrayphp 2b array 5b 5d 5b 5darray assoc phpphp access an arrayset associative array phpin array associative array phpphp get array elementdeclare associative array in phpphp create associcitive arrayphp initialize associative arrayassociative array key value phphash array phpassociative array and valuesassociative array in phpprint key element of a on associative array weschoolscreate associative array php functionmake associative array phpshow associative array with functions in phpphp associative array with arrayphp associate associative arrayassociative arrays arrays phpphp associative array in array examplenew array phpassociative arrays keysphp receive associative arrayget values of associative array phpphp construct array associativephp list function associative arrayinarray in associative array phpassiciative arrays in phpassociative array in an associative array phpwhat is setassociativearray 28 29 in phpto assosiative array phphow to use in array in php on associative arraydeclare an associative array in phpcreate associate array with our value in phpassociativee array in phpprint associative array in phpphp associative array phpphp associative array displaymultidimensional assos array phphow to create assoc array in phpphp how to make a array in a associative arrayphp accessing arrayassociative array to variables phpphp array elementassoicated array in phpphp array associativephp associative arrayin array associative array phpexplain associative array and iteration in associative array with example in array php associative arrayarray 5b 5d in phpassociative array in php using integer keysusing list in associative array in phphow to take input in associative array in phpaccess associative array key phpphp associative array in arrayphp list associativeassociative array loopphp new associative arrayhow to assign associative array in phparrray php associative is array associative phphow to traverse associative array named e2 80 98 24numpy e2 80 99 in phpphp associative array functionsphp how to create associative array in phpform of referencing in associative arraysassociative array demo example in phpphp access associative array elementsphp array asociativocreating associative array that calls function in phpkey valu array phpmake simple array from associative phpassociative arra phphow to declare associative array in phpgetting values from associative array phpcreate associatve array phpkeys in associative array phpphp array of stringsphp make an associative arrayhtml associative arraysget value from associative array phpdeclare associative array phpphp create asotiative array from simple arrayaccessing values of associative arrays phpnode in associative arrays in phpphp array associative to simplephp in array associative key specifies index or key of an array element in phpphp variable array declarationassociateive arrays phpaccess element of associative array phphow to output associative arrayassociativve array in phpphp 7 associative array tutorialassosiative array in phphow to define an associative array in phpsymbols used for associative array in phpget array element php associativeassociative array declaration in phpexample associative array phpdefining associative array in phparraays phpphp get associative array valuephp associative array key as variablegenerate associative array phphow to get associative array value in phpassociative array of arrays phpphp define variable arrayphp list for associative arraysarray associativo como fazer phpphp build associative arrayin array with associative array phpis assos array phpassociative array to array phpassosciative array phpaccess value of associative array phpget value from array of associative arrays in phpadd select in associative array phparray element phphow to access array values in phpphp array associative arrayphp array in array with keyassociative arrays php examplesin array php associativearray associative phpfunction for string representation of multidimensional association in phpsurn associative array to simple array phpphp associative array 5cassociative arrayt in phphow to create file and writeassociativea array in phpphp create associative array with keyscommon from associative array in phpassociative array id 2c name 2c city 2c phphow to access the value of associative array in phpin array for associative array with key in phpphp accessing associative arrayarraty phpdeclaring associative array in phpkey value array phpphp constatnt associative arrayassotiev array access associative array php valueph stylized arrayphp array of associative arrayssyntex of associative array in phpphp what is associative arraycan you use a number in an associative array phpphp declare associative array with valuesphp add to associative arrayassociative matrix in phpmake assosiative array from variable phpget associative array values phpassociative array php in arrayphp array index or thrownumeric array phpconvert variables in associative array phpmake assoc array phpphp loop through associative arrayphp associative array syntaxhow to access a value in an associative array phpphpdoc associatif array 24assoc arrayarrays asociativos phpphp make normal array from associative arrayassociative array definition in phpphp key value arraywhat is a php associative array associative array phpphp create named arraycreate an associative array phpprint asociative array phparray php associativephp read associative arrayaccess associative array value phparray slice associative phphow to echo array associative phpcreate associative array phpphp associative array valuesphp define arrayphp associative arrays with integersget all values from associative array phpphp access associative array elementphp associative array in enviromental variablesphp create object from associative arrayarray types in php 7what are associative arrayshow to create an assoviative array in phpassociative array php exampleassociative array php programmaticallyphp associative array into definition listhow to create an associative array phphow to store associative array in phphow to create associative array in phpassociatice array in phpasoc arrayphp associative array to key php associative array values by keryphp value associate arraywhat does that mean name 3d 22array 5bis 5d 22 phphow to use associative array in phpphp associative array as parametersaccessing elements of an associative array phpaccessing key in an associative array phphow to make an associative array in phpassociative array to phpassociative arrays phpassociative array and numeric array in phphow to echo associative array in phpstore value in associative array phpassociative array phpphp create table from associative arraystring to create associative array phphow to write a associative data array in phpassocative array phgpassociative array type phpphp associative arrays increment value of a keyaccess element in php assiciative arrayhow to access the values from a php associative arrayassociative index array phpphp associative array with variable keyphp assoziative arrayscommon from associate array in phparray associativephp access value in associative arrayphp has an associative arrays and it hasassociative array inphpphp arrays of typeassociative array of associative arrayswhat are associative arrays in phpphp associative array thisfor loop php associative arraydefine variables in array phplocahost 2fphp 2fassociativearray phpassoiciated arrayphp assotive arrayrelational array phpuse of associative array in phphowt to print associativ array with loop in phppass associative array to function phpassociative matrix phpmake associative array in phpphp 22 3d 3e 22w3schools php key value arrayhow to create an associative array in phpget value in associative array phpwhat is associative arraysphp initialize array associativearray string keys phpassociated arrat phphow to loop associative array phparray associativa de 3 phpassociative array example phpphp array shorthand versionarray assco in phpdataarray phpassoc array how to make phphow to echo array associativeassociative array create associative array in phpassociative array inside associative array in phpin array associative values phpphp function in associative arrayhow to display associative array in php 25 associative array key in phpphp associative array of arraysassociative arrays arrays phpphp define array associativeassociative array in associative array phpusing in array with associative array phpphp associative array examplecan you make an associative arrays of arrays in phpassociate arrayassociative array by value phphow to declare empty multidimensional array in phpphp associative array inside associative arrayphp array assoccreate associative array from array phphtml associative arrays to phpcreating assoc array in phparray asociativo phpphph keyed arraysnumeric array and associative array in php how to access elements in phpget value from associative array in php in arraylist php associative arraywhat is an element in associative arraycreate associative array in php from arrayphp array associativoassociative array examplephp can the value in associative array be a functionphp initialize associative array with valuesforeach on associative array phpassociative array in php exampleexplain associative array in phpnamed array in phpphp associative array with functionwhat is a assoictive arraykey value array 5bh 5bassociative phpcan we use function in an associative array in phpassoc arr phphow to elements in associative array with the values in phpphp create associative array from valuesphp for associative arrayarrays asociativos en phpprint assosiative array foreachhow to construct associative array in phphow to create assoc arrayphp key of associative arraycreate named array phpassociative array php dummyassosative array in phpphp creating associative arrayhow to create file and write associativea array in phparray associativo phpphp access associative arraywhen is an associative array best used in phpcreate associative array object phpcreate an associate array in php and display the key 2f value pairs b implement sorting algorithems in the above associate array c implement unset 28 29 2cprint r 28 29 2cvar dump 28 29php how to an element in an associative arrayarray in associative array phpphp associative array 5b 5dassociative php arraysphp associative array arraycreate associative arrays phpget values array of associative array phpcreating associative array in phppost data to associative array phpassociative array how to make phpdata php associative array diplaying on page why 3fkey value array in phpnamed arrays phpphp associative arraysarray that contains associative arrays phpforeach associative array phpphp associative array with associative array to only associative arrayphp create associative array from associative array valuesaccess array of associative array phpassoc array phpasarray in phpwhat kind of arrays are used with posthow to create array inside associative array in phpassociative array php valuephp get associative array from arrayarray of numbers in phpphp define array with type associtive array in phpassociive array in phpways of accessing associative array in phpphp loop associate arraydefine associated array phpphp associativearraycreate associative array phpassociative array php programallyphp define variables from array associativehow to encode associative array in phphas array in phparray associativa phpphp declare array typeassociatie arraysphp initialize dictionaryarray of words php 25whow to use in array in associative array in phpphp array associative examplephp associative array ne demekcreate associative arrayassocioatve array php inteegersassoicatea arraywrite php script to demonstrate use of associative arrays and for for each loop execution php array of associativesphp name arrayphp object values to associative array php in array assocuativephp create a table using associative arraycreate a associative array in phpphp array named keysread associative array in phpaccociative array in phpfunction for assuseitn array in phpasosiativ arraysassociate array in php 24array phpphp echo associative array valuegiven associative array is or not in phpphp array of variablescreate an associative array from an array phparray assoc in array simple phpfunction inside associative array in phppreparing associative array phphow to make associative array in phpvariable in an array phpphp 5b 5dphp array string as keyphp associate arrayin which type of array each id key is associated with a value in phpassociatve arrray phpphp associative arratswhile associative array phploop associative array phpphp declare an associative array 28associatieve 29 array phpwhat is associative array in php 5b 5d phpphp initialise associative arraydeclaring an associative array inside a php classcreate new associative array phpphp print associative arraywhat is linear array in phpassociative array keys phpphp access array 1php write to associative arrayhow to craete assiciative array in phpassociative array in other assosiative array in phpaassociative array in phplista asociativa array phpphp get values of associative arrayassociative array for loop phpphp hash arrayassociative array in array phpphp create associative array from variablesphp accosatiov arrayphp array associativphp asociative arrayphp associative arrayphp assoc arrayhow to access associative array in phparray assoc in array phpphp associative array 5cphp generate associative arrayphp associative array referringphp assosiative arraystore associative array by variable phpassoative array phpun array phprepresent associative array in phpdoccreating a variable that stores an associative array in phparray associatif phpstore value in array in associative format phpread associative array phptaking input to create php asscoiative arrayphp initialized associative arrayhow to create file and put associativea array in php why we use associative array in phpassociative array in php dphp sub assos arrayphp make array associative ararayphp create new associative arrayindex and associative array in phphow to get element from associative array phpassoicietive array in phpphp collection to associative arrayhow to gett the prroperty value of the array inside the array phphow to construct associative array for values in phpphp create associative array with key valuehow to iterate associative array in phpassociative array initialize in phpwrite php program to accept associative arrayphp array assoziativphp create assciative arrayphp associative array of associative arraysphp create assoc arrayhow to get value in associative array phpcreate an associative array in phpphp spread associative arrayconvert associative array to variables phpphp multiple array int valueswhat is an associative array in phpcreating an associative array in phpmultidimentional associative array phpphp associative array values onlyin assoc array phpphp associative array with numeric keyshow to print php assoc arraystring associative array in phppass data to associative array phpassociative arrayphp creat asoiciative arrayphp mysql associative arrayassiositave array phpphp return associative array of associative arraysget values from associative array phparary phpassociative array in 1 array phpstring associative array phpphp usrot associative arrayarray 28numeric 2f associative 29 phpassociative php arrayarray of associative array phpphp associative array createphp access value in arraymake an associative array in php array phpphp associative array value is program usingarray to associative array phpphp associativephp make array associativeassociated array in phpphp associative array to variablesassoziatives array phphow to define associative array in phpphp associative array typehintphp associative array key valuein array for associative array phpget value of associative array phpfor loop associative array phpphp array is associativephp array of assosiative arrayshow to correctly get an array in phphow to make array of associative arrayarray with items phpphp create associative array from arraybuild associative array phpphp associative array from w3schoolassign an php associative array to variabledefine associative array phpphp array namedassociative array in php samplephp associative array for loopassosiative array phpmaking associative array phpphp associative array increment value of a keydefine associative array in phpphp array to associative arrayaccess associative array phphow to declare associative arrayassociate from arrayget value from associative array in phpfunction for associative arraysphp call associative arrayphp in array associativecreating array with keys from arrays in phpphp assocative arraytassocioatve array phpphp is associative arraysassociative int array phpphp associative array creating new key and valuephp make associative arrayassociative arry phpassocaite array phpmake array to assoitive arrayphp are all arrays associativegetting associative arrays phpphp list with associative arrayassociative dummy arrayphp named arrayin associative array phparray numbers in phparray in associativeassociative php meaninghow to access an array in phpwhat is associative array exampleassociative array phphow to pass associative array to php functionphp in array associative arrayassociative array with 2akeyhow to create an associative array vs multidimensional array in phparray associativo php examplephp associative array with indexhash array php 5cphp list associative arrayphp in array associativeget associative array value phpecho associative array phpassociative array php key valuearray in pgpassocative array phpphp associative arrays 24value 2b 2bphp is associative arrayhow to print associative array in phpphp create array associativeaccess array with keyphp associetive arraydeclare associative arraay phpphp is array associativephp associative arrays examplenumerci array phpphp array declare typeof numberassociative array arraypractice question of associative array in phpphp create associative arrayassociative array php using array notationphp associative array from 3d and 3bphp associative array define and incrementrequest variable to associative array phpeample of associative array in phpcreating an associative array in a class in phpassociative array keys in phpphp array value 2 variablesphp associative arrays 3ephp value in associative arrayassociative arrays in phpphp associative array by keyhow do you declare an associative array in a class in phpphp make normal array associativewhat is associative arrayphp define associative arrayassociative array in phpassotive array in phpphp ascostive arrayphp associative array tutorialassocaitive arrays in phploop php associative arrayphp declare associative arrayaccessing associative array phpassociative array vs normal arrayinteger in array phpinsedt data through associative array phphow to get value from associative array in phpcreate associative array from db phpassociative array foreach phpstring array in phpassociative array of associative arrays phphow to create an associative array in php