Jump to content

cmb

Recommended Posts

This is the first part of the search script and i was doing some debuging and i cant figure out why this code


if( !($fd = fopen($url,"r")) ){
die( "Could not open URL!" );
}

while( $buf = fgets($fd,1024) )
{
/* Remove whitespace from beginning and end of string: */
$buf = trim($buf);

/* Try to remove all HTML-tags: */
$buf = strip_tags($buf);
$buf = preg_replace('/&\w;/', '', $buf);

/* Extract all words matching the regexp from the current line: */
preg_match_all("/(\b[\w+]+\b)/",$buf,$words);

print_r($words);
}

doubles each associate array like this

Array
(
[0] => Array
(
)
[1] => Array
(
)
)
Array
(
[0] => Array
(
[0] => It
[1] = > was
[2] => November
)

[1] => Array
(
[0] => It
[1] = > was
[2] => November
)
)

When I would expect this

Array
(
[0] => Array
(
)

)
Array
(
[0] => Array
(
[0] => It
[1] = > was
[2] => November
)
)

Link to comment
https://forums.phpfreaks.com/topic/269330-site-search-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.