我有2个文件1.xml
,2.xml
两个都有相似的结构,我想有一个.我尝试了很多解决方案,但我只有错误 - 坦率地说,我不知道这些脚本是如何工作的.
1.xml
:
<res>
<items total="180">
<item>
<id>1</id>
<title>Title 1</title>
<author>Author 1</author>
</item>
...
</items>
</res>
Run Code Online (Sandbox Code Playgroud)
2.xml
:
<res>
<items total="123">
<item>
<id>190</id>
<title>Title 190</title>
<author>Author 190</author>
</item>
...
</items>
</res>
Run Code Online (Sandbox Code Playgroud)
我想创建一个merged.xml
具有以下结构的新文件
<res>
<items total="303">
<item>
<id>1</id>
<title>Title 1</title>
<author>Author 1</author>
</item>
... //items from 1.xml
<item>
<id>190</id>
<title>Title 190</title>
<author>Author 190</author>
</item>
... //items from 2.xml
</items>
</res>
Run Code Online (Sandbox Code Playgroud)
我该怎么办?你能解释一下这样做的方法吗?如何使用更多文件?谢谢
编辑
我尝试了什么?
<?php
function mergeXML(&$base, $add)
{
if ( $add->count() != 0 …
Run Code Online (Sandbox Code Playgroud) htaccess 文件重定向如下:
pagename.com/foo -> pagename.com/index.php?view=foo
它在 htaccess 中的工作代码是
RewriteRule ^foo$ index.php?view=foo [L]
Run Code Online (Sandbox Code Playgroud)
但我也想使用参数。所以看起来是这样的
pagename.com/foo?parameter1=bar -> pagename.com/index.php?view=foo¶meter1=bar
我已经创建的是:
RewriteRule ^foo\?([^-]+)$ index.php?view=foo&$1 [L]
Run Code Online (Sandbox Code Playgroud)
但它无法正常工作 - 我被重定向到查看 foo 但参数未传递
有任何想法吗?先感谢您
编辑:
RewriteRule ^foo/?([^-]+)$ index.php?view=foo&$1 [L,QSA]
RewriteRule ^foo/?$ index.php?view=foo [L,QSA]
Run Code Online (Sandbox Code Playgroud)
既可以单独使用,也可以与
RewriteCond %{REQUEST_FILENAME} !-f
Run Code Online (Sandbox Code Playgroud)
无法得到它
编辑2:
对同一 foo 页面进行了另一个重写规则 - 只是将 QSA 添加到第一个页面,如下所示:
RewriteRule ^foo$ index.php?view=foo [L,QSA]
Run Code Online (Sandbox Code Playgroud)
它有效