如何用简单的html dom解析器修复这个空白区域?

i have find a php snippet that i modify for my need ,it use simple html dom for parse data from a webpage

here is a part of my code

$html = new simple_html_dom();
$html->load_file($page);

$items = $html->find('ul[class=history_list]');  

foreach($items as $post) {
$items = $post->find('li[class=sub_pop_headline]');
$title=$items->plaintext;

foreach($items as $post) {
# remember comments count as nodes
$items_data =  strip_tags($post);

echo $query = "INSERT INTO `mysqltable` ( `entry_id`,`domain_id`, `keyword`, `data`) VALUES  ('',1, '$items_data', 'a:1:{s:11:\"{%KEYWORD%}\";s:11:\"$items_data\";}')";

$query_submit = mysqli_query($conn,$query);

the data are fetched (it work) but they are inserted with a lot of blank space into the sql table

here is what should look like the entry columns keyword & data

my fetched title | a:1:{s:11:"{%KEYWORD%}";s:9:"my fetched title";}

but my code give this as output....

my     fetched              title| a:1:{s:11:"{%KEYWORD%}";s:9:"my     fetched             title";}

as you can see there is a lot of space so this is not correct

thanks you very much for help me , im not really a coder...

Sounds like all you need to do is trim() the title:

$title = trim($items->plaintext);