我的代码中有一个查询过滤器,我希望将这两个查询传递为:
case1
con = {'eq':['case1':dosome]}
case2
con = {'eq':['case1':dosome]}
我需要像这样绑定这两个
{'eq':['case1':dosome],'eq':['case2':dosome]}
关键eq应保持不变。
答案 0 :(得分:2)
为什么不使用具有两个属性的对象,如
{ eq: { case1: dosome, case2: dosome } }
答案 1 :(得分:1)
听起来你想要一个对象数组:
var your_array = new Array();
var con1 = {'eq':{'case1':dosome}}
your_array.push(con1)
var con2 = {'eq':{'case2':dosome}}
your_array.push(con2)
然后,您可以使用这些方法访问数组的部分 - > http://www.w3schools.com/js/js_array_methods.asp
答案 2 :(得分:0)
使用merge()函数。这也会产生错误: ['case1':dosome] 。试试这个
<script>
var obj1 = {'eq':{'case1':dosome}};
var obj2 = {'eq':{'case2':dosome}}
var merge = obj1.merge(obj2);
</script>
希望这有帮助
答案 3 :(得分:0)
你可以试试这个:
$menu = new DOMDocument();
$breakfast = 'Breakfast';
$lunch = 'Lunch';
libxml_use_internal_errors(true);
$menu->load("http://amphl.org/test.xml");
foreach($menu->getElementsByTagName("menu") as $recipes) {
echo '<h3 class="location_date">'. $recipes->getAttribute('servedate') .'</h3>' ."\n";
echo '<h3 class="location_date">'.$recipes->getAttribute('location').'</h3>' ."\n";
$recipe_type = $recipes->getAttribute("mealperiodname");
echo '<h3 class="location_date">'.$recipe_type.'</h3>' ."\n";
echo ' <div class="meal_items">' . "\n";
foreach($recipes->getElementsByTagName("recipe") as $recipe_item) {
echo ' <p class="item_list"><a alt="" href="#">' .
$recipe_item->getAttribute("description") .
'</a></p>' ."\n";
}
echo ' </div>' ."\n";
}