VARCHAR
或TEXT
字段存储字符串,数组可序列化为JSON格式(["苹果","香蕉","橘子"]
)存入字段。 $fruits = ["苹果", "香蕉", "橘子"]; $json_fruits = json_encode($fruits); // 存储时转为JSON
import json fruits = ["苹果", "香蕉", "橘子"] with open('data.json', 'w') as f: json.dump(fruits, f)
<ul id="list"></ul> <script> fetch('/api/fruits') .then(response => response.json()) .then(data => { const list = document.getElementById('list'); data.forEach(item => { const li = document.createElement('li'); li.textContent = item; list.appendChild(li); }); }); </script>
<ul>
、<ol>
、<dl>
结构性。 gzip
压缩传输的JSON数据。交互设计
无障碍访问
aria-label
描述: <ul aria-label="水果列表"> <li>苹果</li> <li>香蕉</li> </ul>
多端适配
使用响应式布局,确保数组列表在移动端以卡片形式展示。
echo htmlspecialchars($user_input, ENT_QUOTES, 'UTF-8');