public function DisplayMenu($buttons)
{
echo "<!-- menu -->
<nav>";

while (list($name, $url) = each($buttons)) {
  $this->DisplayButton($name, $url, 
           !$this->IsURLCurrentPage($url));
}
echo "</nav>\n";

}

    9 days later

    it's correct like this

    foreach ($buttons as list($name, $url))
    {
     $this->DisplayButton($name, $url, 
               !$this->IsURLCurrentPage($url));
    }

    Oh, never mind. list() is used like that for nested arrays. "Today I learned..." 🙂)

    bertrc Hmm...I'd never seen list() used in that context before, so tried it via the command line, and got this (followed by the key => value syntax I've always used):

    $ php -a
    Interactive shell
    
    php > echo phpversion();
    8.2.1
    php > $test = range(5, 10);
    php > foreach($test as list($ix, $value)) {
    php {   echo "$ix = $value\n";
    php { }
     =
     =
     =
     =
     =
     =
    php > foreach($test as $ix => $value) {
    php {   echo "$ix = $value\n";
    php { }
    0 = 5
    1 = 6
    2 = 7
    3 = 8
    4 = 9
    5 = 10
    php >
    
      Write a Reply...