Displaying an associative array in PHP

前端 未结 6 1845
南旧
南旧 2021-01-23 04:20

I am trying to build a function that extracts information from a database and inserts it into an associative array in PHP using mysql_fetch_assoc, and return the ar

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-23 04:54

    If you just want information about what is in the array (for debugging purposes), you can use print_r($array) or var_dump($array), or var_export($array) to print it in PHP's array format.

    If you want nicely formatted output, you might want to do something like:

     $value) {
        echo "";
      }
      ?>
    
    ".htmlspecialchars($name). "".htmlspecialchars($value)."

    This will, as you might already see, print a nicely formatted table with the names in the left column and the values in the right column.

提交回复
热议问题