- 1). Open the IDE (Integrated Development Environment) of your choice.
- 2). Find the PHP code in which you want to create and array of objects. Determine the objects you want to use in the array, as well as the values you want to represent.
- 3). Format the array as follows. Note that the array contains a key (an integer or string) and an associated value. Also give the array a name (in this case, $arr).
<?php
$arr = array("key_string" => "value", 10 => true);
?>
Note the use of both a string and an integer as well as the associated values. - 4). To display a value from an object on variable in your PHP array, echo at a specific index.
Ex: echo $arr["10"];
Will display the value 1, the result of the boolean "true." - 5). Save the changes to your program and test to make sure things are working correctly.
next post