Only first word of title retrieved with PHP showin

2019-02-15 19:23发布

So I am trying to display a list from another website in mine, it all works fine but only the first word of the 'title' attribute is stored. I know that the whole title is retrieved from the other website so how do I get it to store all of it.

Here is the code if it helps.

<?php
include "simple_html_dom.php";
$page = file_get_html("http://www.blade-edge.com/images/KSA/Flights/craft.asp?r=true&db=dunai");
echo "<table id=list>"; 
foreach($page->find('html/body/div/div[2]/ol/a') as $key=>$element) {
    if ($element->title != "No craft within this SOI"){
        $ships[$key] = $element->plaintext;
        $shipTitles[$key] = $element->title;
        $shipLinks[$key] = $element->href;
        echo "<tr>"; 
        echo "<td title =".$shipTitles[$key]." >";
        echo $ships[$key];
        echo "</td>";
        echo "</tr>";
    }
}
echo "</table>";
?>

enter image description here

1条回答
做个烂人
2楼-- · 2019-02-15 20:14

Put title inside quotation marks

echo "<td title =".$shipTitles[$key]." >";   // Wrong

Right is

echo "<td title ='".$shipTitles[$key]."' >";

Without quotes, you will only see the word till the first space

查看更多
登录 后发表回答