我正在尝试弄清楚如何从fieldName数据文件中只返回php键和值,并且能够单独调用它们。
从网络输出返回的信息示例:
"info":"<?php\r\n$dataset->tableName = \"mytable\";\r\n....$dataset->fieldName[0] = \"id\";\r\n$dataset->fieldType[0] = \"int\";...
输出信息的php文件:
$dbfile = "path to php data file";
$info = file_get_contents($dbfile);
returnSuccess($info);
function returnSuccess($info) {
$data=array();
$data['success'] = true;
$data['info'] = $info;
echo json_encode($data);
exit;
}
当在网络数据中返回时,我可以将$info视为一个大字符串,如上面的示例所示。有没有办法获取每个fieldName键和值?我想回到js中,能够调用indiv:
.done (function(data) {
if (data.success == true) {
console.log('1stfieldName: ' + data.info.fieldName[0]);
发布于 2018-07-24 08:42:16
通过添加require_once来拉入数据文件并使用for循环来获取字段名,获得了一个解决方案
https://stackoverflow.com/questions/51488226
复制相似问题