zander1983 Posted April 21, 2010 Share Posted April 21, 2010 Hi I'm a student and new to PHP. I was recently provided with a question which had a funny looking array. My question is, are the '1', 'Phrase', 'e_3', 'key', '15', '9' and 'comment' the keys to the array? As in will print(array['1']) output 'apple' and print(array['e_3']) output 'carrot'? The question is below: Given the following array, remove the letter ‘t’ from every second element and display the contents of the array. $data = array( '1' => 'apple', 'phrase' => 'better', 'e_3' => 'carrot', 'key' => 'rabbit', '15' => 'dog', '9' => 'flute', 'comment' => 'elephant' ); Quote Link to comment https://forums.phpfreaks.com/topic/199205-new-to-php-strange-looking-array/ Share on other sites More sharing options...
Alex Posted April 21, 2010 Share Posted April 21, 2010 Yes, those are the keys. Check the manual for the array syntax. Quote Link to comment https://forums.phpfreaks.com/topic/199205-new-to-php-strange-looking-array/#findComment-1045533 Share on other sites More sharing options...
trq Posted April 21, 2010 Share Posted April 21, 2010 My question is, are the '1', 'Phrase', 'e_3', 'key', '15', '9' and 'comment' the keys to the array? Yes. There is nothing strange looking about that array. Quote Link to comment https://forums.phpfreaks.com/topic/199205-new-to-php-strange-looking-array/#findComment-1045534 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.