美好的一天!我的问题在这里并不常见......有很多类似于我的问题的问题,但是我比较一个是相同的,但他没有像这样声明他/她的变量:$page = array();
,但是我的声明但它仍然是它返回值的第一个字符。
来源:PHP String in Array Only Returns First Character
这是我的代码:
主要的php文件
脚本:
var saveStudRegInfo=[[],[]];
studInfoLN = document.getElementById('studRegLN').value;
studInfoFN = document.getElementById('studRegFN').value;
studInfoMN = document.getElementById('studRegMN').value;
studInfoGender = document.getElementById('studRegGender').value;
studInfoCourse = document.getElementById('studRegCourse').value;
studInfoID = document.getElementById('studRegID').value;
studInfoRFID = document.getElementById('studRegRFID').value;
saveStudRegInfo[0][0] = studInfoLN;
saveStudRegInfo[0][1] = studInfoFN;
saveStudRegInfo[0][2] = studInfoMN;
saveStudRegInfo[0][3] = studInfoGender;
saveStudRegInfo[0][4] = studInfoCourse;
saveStudRegInfo[0][5] = Number(studInfoID);
saveStudRegInfo[0][6] = studInfoRFID;
saveStudRegInfo[0][7] = studPicFilename;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("saveWorkSched").innerHTML = this.responseText;
}
};
xhttp.open("GET", "ajax/saveSAWorkSched.php?studRegInfo="+saveStudRegInfo+"&schedList="+getSAWorkSched+"&studInfoID="+studInfoID, true);
xhttp.send();
saveSAWorkSched.php
$studPerInfo = array();
$studPerInfo = $_GET['studRegInfo'];
$studLN=$studFN=$studMN=$studGender=$studCourse=$studID=$studRFID=$studPicFilename='';
if (!empty($studPerInfo)) {
$studLN = $studPerInfo[0];
$studFN = $studPerInfo[1];
$studMN = $studPerInfo[2];
$studGender = $studPerInfo[3];
$studCourse = $studPerInfo[4];
$studID = (int)$studPerInfo[5];
$studRFID = $studPerInfo[6];
$studPicFilename = $studPerInfo[7];
}
echo var_dump($studLN);
结果将是:
string(1) "d"
这里是整个数组的var_dump
($studPerInfo
)。
string(74) "Dela Cruz,Juan,Masipag,male,BSInfoTech,1234567890,2342342342342,dummy.jpg,"
答案 0 :(得分:1)
你得到的值是字符串,将它用作你需要爆炸的aaray
使用explode。
private void button2_Click(object sender, EventArgs e){
using (WebClient ftpClient = new WebClient()) {
ftpClient.Credentials = new System.Net.NetworkCredential("RAYSOFT", "raysoft");
ftpClient.DownloadFile("ftp://RAYSOFT@192.168.8.101/10001/ajax.txt", @"C:\\SmartProject\ajax.txt");
}
}
答案 1 :(得分:1)
这是字符串值,要将其用作爆炸所需的数组。
$studPerInfo = explode(',', $_GET['studRegInfo']);
print_r($studPerInfo);
将结果输入数组。
答案 2 :(得分:1)
我的建议是首先处理这个客户端。在不知道数组的确切结构或将其分解为单独的查询参数的情况下,将整个数组编码为json并将其解码为服务器端相当容易。尝试这样的事情:
xhttp.open("GET", "ajax/saveSAWorkSched.php?studRegInfo="+encodeURIComponent(JSON.stringify(saveStudRegInfo)));
然后在php中你可以从json解码:
$studPerInfo = json_decode($_GET['studRegInfo'],1);