Will this also work with an associative array? If this is what he is
talking about, I tried it and it does not work....
I put this together though and it works, not sure if it is the *best*
way though...
<?php
$colors =
array('white'=>'#ffffff','black'=>'#000000','blue'=>'#0000ff');
$count = 0;
foreach( $colors as $k => $v) {
$count++;
if( $count == 2 )
echo "\$colors[$k] => $v.\n";
}
?>
-Brad
Jay Blanchard wrote:
[snip]
Is there any way to call for an element value in an array by the
position?
Like position 2 in the array and not the key name.
[/snip]
I hate to say this, but you really need to RTFM http://www.php.net/array
To get a value from position 2 in an array you use $arrayName[1] (all
array elements start numbering at 0, unless you do something to the
array to change it).
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php