Ok so I am trying to get the Related Search terms from MSN Live and put them on my site with my links.
Here is the test code I am using.
It works fine as you can see on my test pagePHP Code:<?php
include 'simple_html_dom.php';
$html = file_get_html("http://search.live.com/results.aspx?q=house&form=QBLH");
foreach($html->find('div[class=qscolumn]') as $related) {
foreach($related->find('li') as $related2)
echo '<a href="http://kywordpro.com/txt/1/10/' . $related2->plaintext . '.html" target="blank">' . $related2->plaintext . '</a><br /> ';
}
?>
The problem is I want to use this code with it
To make the links internet freindlyPHP Code:$search = array(' ', '&','(',')',',','%');
$replace = array('+', '%26','%28','%29','%2C','%25');
$subject = $related2;
$relatedurl= str_replace($search, $replace, $subject);
so my complete code would be
The problem is when I use teh code as a whole it only displays the last array.PHP Code:<?php
include 'simple_html_dom.php';
$html = file_get_html("http://search.live.com/results.aspx?q=house&form=QBLH");
foreach($html->find('div[class=qscolumn]') as $related) {
foreach($related->find('li') as $related2)
$search = array(' ', '&','(',')',',','%');
$replace = array('+', '%26','%28','%29','%2C','%25');
$subject = $related2;
$relatedurl= str_replace($search, $replace, $subject);
echo '<a href="http://kywordpro.com/txt/1/10/' . $relatedurl->plaintext . '.html" target="blank">' . $related2->plaintext . '</a><br /> ';
}
?>
Can anyone help?
Tim...



Reply With Quote
Bookmarks