note 34807 added to ref.xml

From: Date: Thu, 07 Aug 2003 07:32:29 +0000
Subject: note 34807 added to ref.xml
Groups: php.notes 
Request: Send a blank email to php-notes+get-53556@lists.php.net to get a copy of this message
Create a MYSQL QUERY from a XML content... <? $content .= "<test>\n"; $content .= " <name>gh</name>\n"; $content .= " <cell>909</cell>\n"; $content .= "</test>\n"; $content .= "<test>\n"; $content .= " <name>ddd</name>\n"; $content .= " <cell>456756756745</cell>\n"; $content .= "</test>\n"; $content .= "<xxx>\n"; $content .= " <name>vbn</name>\n"; $content .= " <cell>343434</cell>\n"; $content .= " <aaa>3sdf34</aaa>\n"; $content .= " <bbb>3sdf34</bbb>\n"; $content .= " <ccc>3sdf34</ccc>\n"; $content .= "</xxx>\n"; preg_match_all ("/<(.*?)>(.*?)<\/\\1>/is", $content, $tag); while (list($k, $v) = each($tag[2])) { $names = $values = ""; preg_match_all ("/<(.*?)>(.*)<\/\\1>/i", $v, $out); while (list($j, $v2) = each($out[2])) { if ($names) $names .= ", "; $names .= $out[1][$j]; if ($values) $values .= ", "; $values .= "'".$out[2][$j]."'"; } if (($names) && ($values)) { echo $query = "INSERT INTO ".$tag[1][$k]." ($names) VALUES ($values)\n"; } } ?> ---- Manual Page -- http://www.php.net/manual/en/ref.xml.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34807 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34807&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34807&report=yes

« previous php.notes (#53556) next »