我正在尝试从数据库查询生成 xml。
这是生成的 xml 链接:http : //mydeal.ge/api/xml
但是当我尝试解析这个 xml 时,我收到一个错误:http : //wallsparade.com/test.php。
我的代码是:
public function xml()
{
$res = $this->db->query('custom query');
if($res->num_rows() > 0)
{$output = '<?xml version="1.0"?>'. "\n";
$output .= "<deals>";
foreach($res->result() as $item)
{
$output .= "<sale id = '".$item->id."'>";
$output .= "<link>".$item->link."</link>";
$output .= "<title>".urlencode($item->title)."</title>";
$output .= "<image>".$item->image."</image>";
$output .= "<text>".urlencode($item->text)."</text>";
$output .= "<time>".$item->time."</time>";
$output .= "<price>".$item->price."</price>";
$output .= "<parcent>".$item->parcent."</parcent>";
$output .= "</sale>";
}
$output .= '</deals>';
}
echo $output;
}
Run Code Online (Sandbox Code Playgroud)
什么是问题?
我有一个file.txt包含以下内容的文件:
6,73,6,71
32,1,0,12
3,11,1,134
43,15,43,6
55,0,4,12
Run Code Online (Sandbox Code Playgroud)
这段代码可以读取并将其提供给锯齿状数组:
string[][] arr = new string[5][];
string[] filelines = File.ReadAllLines("file.txt");
for (int i = 0; i < filelines.Length; i++)
{
arr[i] = filelines[i].Split(',').ToArray();
}
Run Code Online (Sandbox Code Playgroud)
我将如何做同样的事情,但使用2D阵列?
我有c ++的小代码,有构造函数和析构函数.
#include <iostream>
using namespace std;
class K {
public:
K(){cout<< "3 ";}
~K(){cout<< "1 ";}
};
int main()
{
{
K a;
{
K b;
}
{
K c;
}
}
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
问题: 我不明白为什么答案是:331311
而不是:333111.
我知道第一次运行构造函数和最后的析构函数但是反转.