Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'db.php';
- $file = simplexml_load_file("file.xml");
- // substr('asshole', 0, -1) обрезать последний символ !!!!
- function parser ($par1){
- global $file;
- if($par1!='readinesses'){
- $par2 = substr($par1, 0, -1);
- }else{
- $par2 = substr($par1, 0, -2);
- }
- $parser = $file->$par1->$par2;
- foreach ($parser as $out) {
- $id = $out['id'];
- $title = $out['title'];
- $result = mysql_query("INSERT INTO `he78parse`.`{$par1}` (`id` ,`title`) VALUES ('$id', '$title')");
- }
- if($result==1){echo "Операция выполнена успешно<br/>";}else{echo "Не удачно<br/>";}
- }
- parser("builders");
- parser("townareas");
- parser("streets");
- parser("metros");
- parser("readinesses");
- parser("buildingTypes");
- parser("facings");
- parser("apartmentTypes");
- parser("roomNumbers");
- // $data = parser("townareas","townarea");
- // echo $data;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment