<?php
$dom_xml = new domDocument();
$xml= <<<XML
<car>
<model>volvo</model>
<model>Lada</model>
<fdsdf>Lada</fdsdf>
<qwqw>Lada</qwqw>
<model>Lada</model>
<fdsdfsdfs>Lada</fdsdfsdfs>
<sd>ASD</sd>
<bv>213</bv>
</car>
XML;
$dom_xml->LoadXml($xml);
$dom_xml->formatOutput = TRUE;
$car = $dom_xml->getElementsByTagName("car")->item(0);
$car_childs = $car->childNodes;
$dom_items = $dom_xml->createElement('items');
foreach($car_childs as $mod){
if($mod->tagName != null){
$dom_element = $dom_xml->createElement($mod->tagName, $mod->nodeValue);
$dom_items ->appendChild($dom_element);
}
}
$dom_xml ->appendChild($dom_items );
//удаляем узел car
//$dom_xml->removeChild($car);
$xml= $dom_xml->save('new.xml')
<?xml version="1.0"?>
<car>
<model>volvo</model>
<model>Lada</model>
<fdsdf>Lada</fdsdf>
<qwqw>Lada</qwqw>
<model>Lada</model>
<fdsdfsdfs>Lada</fdsdfsdfs>
<sd>ASD</sd>
<bv>213</bv>
</car>
<items>
<model>volvo</model>
<model>Lada</model>
<fdsdf>Lada</fdsdf>
<qwqw>Lada</qwqw>
<model>Lada</model>
<fdsdfsdfs>Lada</fdsdfsdfs>
<sd>ASD</sd>
<bv>213</bv>
</items>
public class Sender extends AsyncTask<String, Void, String>
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.*;
String json = "[[{o:'-12188866'},{o:'-175'}],[{g:78554274,t:30718264}]]";
Type listType = new TypeToken<List<List<Map<String, String>>>>(){}.getType();
Gson gson = new GsonBuilder().create();
List<List<Map<String, String>>> list = gson.fromJson(json, listType);
const newArr = arr.slice(-5);
arr.splice(0, arr.length - 5);
const arr = [6,4,4.5,3.5,5.5,3,6.5];
const middle = [...arr].sort((a, b) => a - b)[arr.length / 2 | 0];
var nowtime = "17:00"
var oldtime = "19:00"
function extractTime(str){
const [h, m] = str.split(':').map(v => +v)
const d = new Date();
d.setHours(h);
d.setMinutes(m);
d.setSeconds(0);
return d.getTime();
}
extractTime(nowtime)-extractTime(oldtime);
var nowtime = "19:00"
var oldtime = "17:00"
<?php
$arr1 = array('Запись 1',
'Запись 7',
'Запись 2',
'Запись 3',
'Запись 1',
'Запись 4',
'Запись 5',
'Запись 2',
'Запись 6',
'Запись 7'
);
$arr2 = array_unique($arr1);
$arr3 = array_unique(array_diff_assoc($arr1,$arr2));
$.ajax({
type: "GET",
url: link,
crossDomain: true,
contentType: "application/json; charset=utf-8",
data: {},
dataType: "jsonp",
success: function(data){
console.log(data)
}
});
function search( search, subject, before) {
var limit = subject.indexOf( before);
if( limit == -1) return -1;
return subject.substr(0, limit).indexOf( search);
}
search( 'строка 2', 'строка 1 строка 2 строка 3 строка 4', 'строка 3') // 9
str.substr(0,41).indexOf('что ищем')