KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a simple associative array. <?php $assocArray = array('a' => 1, 'b' => 2, 'c' => 3); ?> Using only while loop, how can I print it in this result? $a = 1 $b = 2 $c = 3 This is my current solution but I think that this is not the efficient/best way to do it? <?php $assocArray = array('a' => 1, 'b' => 2, 'c' => 3); $keys = array_keys($assocArray); rsort($keys); while (!empty($keys)) { $key = array_pop($keys); echo $key . ' = ' . $assocArray[$key] . '<br />'; }; ?> Thanks.
Tags (comma-separated)
Save Edits
Cancel