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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.