Is it possible to get the array key name this way?
$array = ("first" => 1);
function f($object)
{
echo(???); //should give first
}
f($array['first']);
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 not possible if you pass only the value into the function like
f($object['first']), the key name has no relation to the passed value in that case.You need to pass the entire array (
f($array)) and use: