问题
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>";
?>

回答1:
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
来源:https://stackoverflow.com/questions/28283104/only-first-word-of-title-retrieved-with-php-showing