Brant Snow
asked on
PHP using and referencing arrays
So i have my two examples below, the first one is working but what i really want is the second one but i cant seem to get it to work.
<?php
$section = array(
"first" => "its the first",
"second" => "its the second"
);
echo( $section["first"] ); /* this will print out 'its the first' What i really want is below but cant get it to work*/
?>
<?php
/* i cant get this to work but it is what i want */
$section = array(
"first" => ["its the first","im still first","3rd part of first"],
"second" => ["its the second","im still second","3rd part of second"]
);
echo( $section["first"][2] ); /* this should print out "3rd part of first"*/
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
great
http://php.net/manual/en/book.array.php
http://php.net/manual/en/language.types.array.php
http://php.net/manual/en/language.operators.array.php
You also want to know about foreach() and for() which are both useful with arrays.
http://php.net/manual/en/control-structures.foreach.php
http://php.net/manual/en/control-structures.for.php
Best of luck with it, ~Ray