This php is for getting input that was entered by user in the textbox. The user will only input one keyword per line.After pressing “Run” button, those keywords will be saved in an array and written to the “test.txt”. And then it gets each keyword from the txt file and each keyword will be passed to simplexml_load_file() to be an object.
I know I can get each keyword correctly. But the problem is after going through simplexml_load_file(), the link becomes [url]http://localhost/xampp/example%3Cbr+%2F%3E.xml
Here is the warning message:
Warning: simplexml_load_file([url]http://localhost/xampp/example%3Cbr%20/%3E.xml
[code=html]<form action=”new.php” method=”POST”>
<textarea name=”keywords” cols=”70″ rows=”10″></textarea><br />
<input type=”submit” name=”run” value=”Run”>
</form>
[code=php]
$items = $_POST[‘keywords’]; //store all keywords input in an array
$tobr = nl2br($items);
$tobr = str_replace(array(“rn”, “r”, “n”), “:”,$tobr); // separate each keyword in array
$newinfo = split(“:”, $tobr);
$filename = ‘test.txt’;
$fh = fopen($filename, ‘w’);
for ($i=0; $i<sizeof($newinfo); $i++) {
if ($filename)
fwrite($fh, $newinfo[$i].”n”);
}
fclose($fh);
$file = file(‘test.txt’);
foreach ($file as $content_hs) {
$url1 = “http://localhost/xampp/”;
$url2 = “.xml”;
$url = $url1.rtrim($content_hs).$url2;
$xml = simplexml_load_file($url);
}