I have an array:
$array = [
"sdf" => 500,
"gsda" => 1000,
"bsdf" => 1500,
"bads" => 2000,
"iurt" => 2500,
"poli" => 3000
];
How can I get the name of the next key? For example if the current array is gsda, I need bsdf.
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.
Update: Note that this is not a valid answer, as it’s searching for values instead of keys.
If the pointer of
current()is on the right key, @Thomas_Cantonnet is right and you want to usenext(). If you did not iterate through the array via next(), you first have to go through the array to set the internal index pointer correctly:Now $next points to your current search-index and you can iterate over the rest via
next().