Access array element within same array
Is this possible in PHP?
$a = array('first' => 'some value', 'second' => $a['first']);
Simply accessing an开发者_运维问答 array element within another element from the same array.
Not with this syntax, because at the time $a['first']
is evaluated, $a
is undefined. This would work though:
$a = array();
$a['first'] = 'some value';
$a['second'] = $a['first'];
精彩评论