php - 如何将数组值插入数据库
问题描述
我想知道如何将 'peter'、'paul'、'mary' 置换值插入 phpmyadmin 数据库。我的数据库 (id,name1,name2,name3) id 是自动递增的。
<?php
function pc_permute($items, $perms = array()) {
if (empty($items)) {
echo join(' ', $perms) . "<br />";
} else {
for ($i = count($items) - 1; $i >= 0; --$i) {
$newitems = $items;
$newperms = $perms;
list($foo) = array_splice($newitems, $i, 1);
array_unshift($newperms, $foo);
pc_permute($newitems, $newperms);
}
}
}
$arr = array('peter', 'paul', 'mary');
pc_permute($arr);
?>
1 peter paul mary
2 peter mary paul
3 paul peter mary
4 paul mary peter
5 mary peter paul
6 mary paul peter
解决方案
推荐阅读
- apache - 在apache中获取客户端IP
- javascript - 我如何获得类(css)数组的索引
- azure - Azure 服务终结点和专用终结点
- html - ```高度:100vh```和页面底部的白色边距的意外行为
- reactjs - ReactJs:如何在从不同设备或单个设备填写表单时增加用户数量作为 id
- ios - IndexPath 返回 nil,仅在 iOS 13.5.1 上用于 indexPathForRowAtPoint
- c# - 如果选中 DataGridCheckBoxColumn,则从 DataGrid 获取数据
- javascript - Discord.js:尝试使用 discord.js 机器人在两个不同的服务器之间创建消息系统
- flutter - 未使用局部变量的值
- clickhouse - 点击屋:information_schema.KEY_COLUMN_USAGE