Good day folks!
I am just getting start in PHP and really could use some help.
I am trying to export an array into a XML file.
Some Background:
I currently working with a PHP class (Media Grabber) that grabs images from a URL, sorta like facebook & google.I am having issues posting that data after it has been captured.
Here is the process flow
I am stuck after $imageMediaGrabber has the array. Please advise as to how I can export to XML. Please take a look below and let me know what you think. The code in question is 2 or 3 lines from the closing php tag. A million thanks!
<?php
include 'tut/connect.php';
require_once dirname(__FILE__)."/bin/wlWmg.php";
require_once dirname(__FILE__)."/demo-utils.php";
$url = wlWmgUtils::getArrayValue($_POST, 'user_url', wlWmgUtils::getArrayValue($_GET, 'user_url', null));
?>
<?php
if (isset($_REQUEST['Submit'])) {
# THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE
$sql = "INSERT INTO $db_table(user_name,user_url) values ('".mysql_real_escape_string(stripslashes($_REQUEST['user_name']))."','".mysql_real_escape_string(stripslashes($_REQUEST['user_url']))."')";
if($result = mysql_query($sql ,$db)) {
echo '<h1>Thank you</h1><br/><p>Your information has been entered into our database</p>"';
} else {
echo "ERROR: ".mysql_error();
}
} else {
?>
<form action="" id="form" method="POST" enctype="multipart/form-data">
<input type="text" name="user_name"><br>URL <br>
<input type="text" name="user_url" id="user_url" value="
<?php echo isset($url) ? $url : 'http://cnn.com';?>"/>
<input type="submit" name="Submit" value="Submit"/>
</form>
<?php
}
?>
<?php
if(!$image_extensions_active) {
$image_extensions = null;
}
//the magic starts here ...
//creating the image grabber object by giving some necessary parameters:
//$url: url,
//$image_extensions: the image extensions to grab (null means all)
$imageMediaGrabber = new wlWmgImageGrabber($url, $image_extensions);
//set download switch: if the images should be downloaded to localhost
$imageMediaGrabber->setDoDownload($download);
//limit filter: setting the media limit count to be grabbed
if($limit_active) {
$imageMediaGrabber->setLimit($limit);
}
//the processor will grab only the media founded inside the contents of the tag specified here
if($tagslice_active) {
$imageMediaGrabber->setGrabOnlyFromTagSlice($tagslice);
}
//grabbing
if($url) {
$imageMediaGrabber->grab();
//HOW DO I GET THIS EXPORTED TO XML
echo '<pre>'.print_r($imageMediaGrabber->getValidMediaNames(true), true).' </pre>';
}
?>