home
search
help
profile
liking the experience? our app is even better
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now  
showing results for php declaring array with values of type int
1$array = array(
2    "foo" => "bar",
3    "bar" => "foo",
4);
upvote
downvote
source
1$array = array(
2    "foo" => "bar",
3    "bar" => "foo",
4);
5
upvote
downvote
1#Arrays
2
3<?php
4    #array is a variable that holds multiple values
5    /*
6    Three types of arrays
7        - Indexed
8        - associative
9        - Multi-dimensional
10    */
11    // Indexed array is the most common and easiest
12    $people = array('Kevin', 'Jeremy ', 'Sara');
13    $ids = array(23, 55, 12);
14    $cars = ['Honda', ' Toyota', 'Ford'];  // also an array
15    //add to an array
16    $cars[3] = ' Audi';
17    // you can use empty brackets and it will be added to the last one
18    $cars[] = ' Chevy';
19
20    echo $people[1];
21    echo $ids[1];
22    echo $cars[1];    
23    echo $cars[3];
24    echo $cars[4];
25    echo count($cars);
26    //you can also print the entire array
27    print_r($cars);
28    //to look at data type
29    echo var_dump($cars);
30
31    //Associative Arrays key pairs
32    $people1 = array('Kevin' => 35, 'Jeremy' => 23, 'Sara' => 19);
33    $ids1 = array(23 => 'Kevin', 55 => 'Jeremy', 12 => 'Sara');
34    echo $people1['Kevin'];
35    echo $ids1[23];
36    //add to these types of arrays
37    $people1['Jill'] = 44;
38    echo $people1['Jill'];
39    print_r($people1);
40    var_dump($people1);
41
42    //Multi-Dimensional Arrays aka an array within an array
43 
44    $cars2 = array(
45        array('Honda',20,10),
46        array('Toyota',30,20),
47        array('Ford',23,12)
48    );
49
50    echo $cars2[1][0];
51
52    
53?>
upvote
downvote
1$my_array = array();
upvote
downvote
1// sequential array
2$arr = array(
3  'v1',		// $arr[0] == 'v1'
4  'v2',		// $arr[1] == 'v2'
5  'v3'		// $arr[2] == 'v3'
6);
7// or (since PHP 5.4)
8$arr = [
9  'v1',		// $arr[0] == 'v1'
10  'v2',		// $arr[1] == 'v2'
11  'v3'		// $arr[2] == 'v3'
12];
13
14// key accessed array (map like)
15$arr = array(
16  'k1' => 'v1',		// $arr['k1'] == 'v1'
17  'k2' => 'v2',		// $arr['k2'] == 'v2'
18  'k3' => 'v3'		// $arr['k3'] == 'v3'
19);
20// or (since PHP 5.4)
21$arr = [
22  'k1' => 'v1',		// $arr['k1'] == 'v1'
23  'k2' => 'v2',		// $arr['k2'] == 'v2'
24  'k3' => 'v3'		// $arr['k3'] == 'v3'
25];
upvote
downvote
1
2<?php
3$array array("foo""bar""hello""world");
4var_dump($array);
5?>
6
7
upvote
downvote
queries leading to this page
declaring arrays phpdefining an array in phparray concept in phppgp arraysphp array strijg index 1 to 5php array with variablesphp arayphp array typesphp array 281 29php arreyassgin values in array phpnew value in create array phpmanuall array takingphp array 3ephp number arrayname an array in phpmethod array phpphp create new arrays from arrayarray declare in phpdeclare an array in phpphp array 28 29php arraycreating an array phpphp make an array based on html elementsphp array syntaxarray 28 5b0 5d 3d 3e 7bphp array declarationmphp array literalsphp array with keysarray php declarephp array with a string indexaray phpsingle dimensional array in phpas array phpdeclaring a array in phparray create in phpphp types of arraysnew php creating new arrayarrray in phpaccess 23items phphow to declare an array phpfunction creat array pohp 24var 5b 27 27 5d 5b 27 27 5d php array with an arrayw3schools php array with colorsphp initialize object associative arrayhow to define a vector in phpaccess array 0 phpphp array in array pointset value to array pphphp things you can do with an arrayassign array phparray syntax in phpphp declare array matrixphp array of arraysbuilding array phpphp making arrayarray of arrays phpdeclare integer arry php 40array in phpaccssing array phpnew array phpcreate array in dictionary phparray php typedeclare array variable phpphp indicate variable as arraydeclare a array in phphow to create the array in phpphp types of arrayphp initialize array stringphp array 2bnew array string phpphp initialize class associative array with valuesarray of arrays in phparray de numeros phpphp 7 array multiplearray with variables phpphp type declaration arraystore data in php arrayuse array index phphow to make and array in phptoponimo array phpphp set values to an array in htmlarray 28 29 phphow to make a array phpnew item in php arrayhow to get data from array in phpdelcre a array phparray declaration phpphp arracraete array in phpphp array as matrixhow to create array phpbuild an array in phparr phpphp arryphp create array of variablesnew array 28 29 in phpphp array createtypes of array in phpget direct value from php arrayassign 24variable of key value pair array to multiple variables phpcommon array methods phpdictionary in phpphp method arrayphp get array php array usebest way to declare array in php array in phpphp array with arraysphp arrayshapephp array on htmlphp variable arraydeclare integer array phpvar array in phpphp index array elementsphp array of stringsdeclare array phphcreate a standard array in phpphp arrays w3php declare array parameterin array pphmeaning of 5b 5d and 7b 7d in array phpphp access arrayphp array by idphp how to assign values to an arrayphp array valuephp array 3d 3ehow to use array in phphow to create new array in phparray in php make sure array in javascriptset your own int array keys phpphp associative array with numbershow to strore an array value to variable in phparray php w3schoolsthree different kinds of arrays in phphow to create arrays in phphphp declare array of arraysmake array in phparrays php w3schoolsarray 5b0 5d in phptypes of arrays in phpset array in phpphp make arrays type of array in phparray in php with examplephp create an arrayhow to assign values in php arrayphp arrraywrite array phparray vs string in phpphp access array element with variablephp make an arraymaking an array in phpdefine array phpphp creat arrayphp new array 28 29 3d array 28 29 phpphp create array with variablescreating a php arrayphp array getaccessing the array in phparray php key and valphp define a few variables all array shortcutarray element phpcreate array in phpphp define array key valuehow declare arr in phphow do do array in phpphp create array with dataarra phpcreaet new array in phpphp defining arraydefine new array phparray in new array in phpdeclare array phpphp how to create array of arrayscreate any aray phpphp array 2b array 2b arrayphp create new arraydeclare dynamic array in php on a loopphp array kindarraty phpphp array definehow to create arrayy in phpphp assign index to arraytype of value of array phpph stylized arraydefine array with values phpphp make array value as arrayhow can you declare the array in php 3f explain with examplecreate array with the values of array phphow can we write arrays in phpquick way to declare array phphow to declare array in php with bewphp array index or throwarry phparrray phparrays and its types with example in phpphp atrrayphp create array with keysdoes anyone use psuedo array name in phpphp load arraydata array in phpphp create simple array and print value at indexphp key value arrayphp assign a value or default using an array indexdeclarer array phpget array phphow to define arrays in phphow to add a defination array in phpmake array simple phpphp define arrayphp array tutorialhow to make an array in hassociative array php example 40var array phpdeclaring a an array in phpphp create simple arrayphp creating arryahow to make array values to be different variable phphow to define a new array in phpdictionary phparray key named class phpdefinine array in phpphp array 22 22use name of array and not it 27s values phpcreate array of array data phphow to define php arrayhow to define array in phpphp array new array elementrray phpcreate a php arrayphp array normal dataecho 24fruits 5b 3a 5d phpphp declare variable arrayphp int arraywrite array php in codedifferent ways to declare an array in phpcreate arrayphp initialize an array of arraysphp new arrayhow declare array in php 7how array is declared in php 3fdeclaring arrays in phpfunction of arrays phparray in php example 5bphp arrayassociative array type phparray program in phpall array examples in phpdeclare new array in phpcriar array for phparrary in phpphp array array with numbers phpgenerate array from variables phparray data type phpphp array multipl types cannot echodefining key value array in phpphp arrayinitialize matrix ohohow do you create an array in php examplephp indexed array view 3 conditionsdeclare array in phphow make to array new in phpasign value to theh array phpdefine variables in array phplaravel array typeshow to use an array phpdefine new array variable in phpphp use variable as array indexuse array phphow to create array of array in php 24array in phpwhat type array in phpphp define string arrayphp array declarationfunction set array phpaccess array element phparray value phphow to build an array in phparray in phpphp set of arratphp array functionphp multidimensional array not numberedhow to set array phparray as a variable phpmake array from phpparsing arrays inside of a key phpphp array value accessphp arrayphp array of namesvariable arrays phparray variable declare syntax in phphow to create array in phphow to make array in phparray functions phphow to make make an arrat in phpmaking array in phpphp 3 types of arraysdefining array in phpdefine an array phpphp qarraycreate array phpworking with arrays phpcreate array list in phpmake a array in phpdid php 1 had arraydeclare an arrayy in phpphp arraysphp array variable declarationphp array dictionaryphp declaring arrayphp declare array with keys in arraycrear array phpphp array data typenew array 28 29 phpphp arratphp define array of arraysaray 5b 5d phpphp arot arrayhow to define new array in phpselect inside php arraydefine php arrayphp set array formatphp access array datacreating array of arrays in phparray declaration in php array phpphp array codephp declare array variablephp how to create arrayphp get arrayphp receive a array or variablearray variable declaration phparray methods in phphow to access array element in phpdeclare array variable in phpphp array data callphp arrhow to work with arrays in phparray creation phparray 5b0 2c 22 22 5d phpphp declare variable as array of intphp variablearraydecalre array in phpphh arrayphp array new array 28 29php declare an arrayhow to declare array variable in phpdeclare variable array phparrau in phparray php 7take array in varaiable phpphp array indicesphp array methodphp create a from arraymatrix phparray value in phpcreate array in php define array in phpphp array 5b 5d typeshow create array phpbuild an array phpphp array from arraydeclaring a variable as an array in phpphp initial arrayarray associative convert to string performance phpdefine an array in phpcreate new array in array phpcreatearray phphow to create an array of items in phpphp get array functionsphp create arrasyntax array phparray bidimensional phparray or 5b 5d to declare aray in phparray php phparray define in phpdeclaration of array in phpmake variable data an array phpnew array declare phphow many way to create array in phpw3c php arraysphp array 5b1 5dphp creat an arrayarray syntax in phpcreating array phparray how to make phparray declarations in phpphp create array of arrayphp do arrays always have number keysarray value to create new array phpnamearrys arrayphp create arrat 5b 1 5d array phpint array phpphp element how to read array in phparray in php with examplesdeclare aarry phpphp array 26 declare an arry phpcreating array of array phpcreate array in array item phparray numbers phpphp array 28x 2cy 29create an array php with arraysphp set arrayarrays phpphp array examplehow to name arrays i phphow to create an array in phpvariables in array phphow to declare an array in phpphp 28array 29making new array in phpddeclare array to no errors php 24array phparray php with varphp array inhow to use array element with variable in phpdefine array variable in phpdisplay multi dimensional array inline phpphp build your own arraysyntax for writing php multiple arrayshow to define a array in phpcreating array with new in phpphp how to create array manualphp initialize array variablearray of array in phparray variables phphow to declare variable in array in phpbasic php array is not an associative arraycreate php arrayarray creation in phpcreate variable from array phpcreate new array phphow to use a variable in an array phphphp building an arrayphp array examplesphp create array with item and value 3d 3e in php arrayphp create array with variable namephp make arraywhat is a php arrayphp declare variable as array 5clearning 5carrarprogram phpdefine new index to array phparray make phpphp array notation with keycorrect way to create an array in phpcreating array in phpwhat is linear array in phpaccess array elements in phpworking with arrays in phpset element at index 8 to 2 in phpphp array functionsphp create array manuallydemo array phpcreate arrays phpplace value from a text in right from 40 in array phpcreate marray phpphp array variablework with array of arrays in phparrays w3schools phpphp create array based on valuearray phpphp make array of x elements by adding constant valuecreate an array phpphp assign array elementassign new content for an array phpcreate a basic array with phparray 28 29 in phpphp declare new arraycreate new array in phpphp declare new arryhow to declare an array variable in phpmake string index in array phpphp create array 2 valuephp declare array with valuesaccess elements in phphow to make an array item reference to file in phparrray recreate phpget an array phpw3 school php arrayarrays in php 5b1 2c2 2c3 5d phparray creation syntax in phparray 28 5b0 5d 3d 3e array 28 5bnumber 5d 3d 3e 1852890147 29 5b1 5d 3d 3e array 28 5bnumber 5d 3d 3e 4581081856 29 php make variable arrayphp set into arrayarray php w3schoolcreate arra phphowt to define array in phpphp build array of arraysmake array phparray new variable phpphp array functionphp arrays functiongettig elemnts of an array phparray with 28 29 in phpphp create array with elementsfor array phpcreating a new array in php using new php declare array how to store all values from an array in phpphp single index array to array not objsyntax for writing php arraysget like elements from array phpphp create an array of elementsindex into array phpphp array indexphp important array functionsphp how to arrayphp read arrayarray 5bi 5d phpcreating an array in phpphp araayshow to make array values to be different variable pphwhat is array in phpphp syntax to create arrayphp is key value arraycorrect way to create array in phpsimple array phpphp make var arraycreate variables from array phpelements in array phpstore values in array phpphp array 2b arrayarray variable phpdeclaring and array phpplace value in right from 40 in array phpwhat is setarray in phpphp define arraarray array array phpphp array valuearray in 7b 7d phpphp array formathow to define an array in php 22in php associative array index can be integer 2fstring 22 2c true 2ffalsecreate array in array phpphp arrazhow to form the array by getting elements from html using phpphp array instancephp array create arrayarray create new phpunderstanding arrays in phpwhich of the following is the correct way to create an array in phpwhich of the following are correct ways of creating an array in phpphp array typephp aray indexsphp array of numbersarray with items phparray function in php to createdeclaring array in phparray types in phparray 2b array phphow to access array inside the function in phpphp arrusartive arrayaccess php arrayphp array operationsphp create arraayhow to create a array in phparrays functions in phpmake an array in php php arrayphp create an array of arraysarray in variable phpphp arrays of arraysfor 28 24arr in arr 29 7b 7d pphcreate a array phpdelare array name htmlarray create phpphp array integercreate am array in phpccreate array phparray function phpphp array arrayassociative arry phpaccess an array from within a function phpread from array phpphp create array valuecreate array php 5dhow to write array in phpdefine new array in phparray 28 24variable 29an array can be accessed using what syntax 3f phpcreate custom array in phpphp array looks like a string needs to be an arrayphp how to define key value arrayphp arr declarehow to declare a matrix in phpphp creating arraycreating an array using phphow to create aaray in phpphp array in sqlcreate and store value in variable by using array phpphp assign value to corespondkey arrayphp create arraycreate array of aaray in php examplearray type phpdiffrent define array in php version 7 2 with php5 6php array set valuesarray manipulation phphow to create a php array with stringsphp array itemcreate array of arrays phpcreate array of array phparray of strings in phpdefine a array of object of values in phpfunction to show array indexes in phparray on phphow to expose array in phphow maje array with static amount phpcreate an array in phpnew array in phpphp array details tutorialcall element of array aphpwhat is php arrayphp array methodshow to make an array in phpphp 3farray 24array in pphhow to create php arrayphp array value 2 variableshow to make a variable an array in phpmake elements array phpphp define an arraydeclaration arrray php how to declare array in php 28array 29 phpdeclare new array phpaccess array php in phpgenerate array in phpphp array multipl types cannot echo 5b 5darray of types phpphp set key when instatiating an arrayphp array in one argumentvariable array php php array index stringhow to define array phpphp array constructorphp new array with valuesphp array newarray 28 29 in phparray program w3schoolsphp create array of arrays