I saw this in a piece of code:
if (some_condition) {
$index++;
}
$index{$some_variable} = $index{$some_variable} + 1;
What does $index{$some_variable} mean? And why is it used?
Thank you.
EDIT:
index is defined as $index=0;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s retrieving an entry in the
%indexhash using a key whose value is the value of$some_variable(Note: There may also exist a scalar named
$indexbut it will occupy a separate namespace. That is, you can have both a hash and a scalar namedindexand they will not conflict.)