Re: Array keys referencing value from another array key???

From: Date: Sun, 06 Jun 2004 22:17:14 +0000
Subject: Re: Array keys referencing value from another array key???
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-187764@lists.php.net to get a copy of this message
Gerard Samuel wrote:
Not sure if the subject was worded correctly, but I was looking to see if this (or something like it) is possible. $array = array('key_1' => 'This is some text',
                        'key_2' => '<b>' .  $array['key_1'] . '</b>'
                      );
And the array structure would be something like -> array('key_1' => 'This is some text',
         'key_2' => '<b>This is some text</b>')
Just wanted to see if it were possible, as my attempts were futile. Its not a requirement on my end, just wanted to see if it were possible... :) Thanks
It is possible in 2 steps: 1. create the array: $array = array('key_1' => 'This is some text'); 2. Add the second key: $array['key_2'] => '<b>' . $array['key_1'] . '</b>';

« previous php.general (#187764) next »