Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9010959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:36:03+00:00 2026-06-16T02:36:03+00:00

I have parsed a doc file to a string. function parseWord($userDoc) { $fileHandle =

  • 0

I have parsed a doc file to a string.

function parseWord($userDoc) 
{
$fileHandle = fopen($userDoc, "r");
$word_text = @fread($fileHandle, filesize($userDoc));
$line = "";
$tam = filesize($userDoc);
$nulos = 0;
$caracteres = 0;
for($i=1536; $i<$tam; $i++)
{
    $line .= $word_text[$i];

    if( $word_text[$i] == 0)
    {
        $nulos++;
    }
    else
    {
        $nulos=0;
        $caracteres++;
    }

    if( $nulos>1996)
    {   
        break;  
    }
}

//echo $caracteres;

$lines = explode(chr(0x0D),$line);
//$outtext = "<pre>";

$outtext = "";
foreach($lines as $thisline)
{
    $tam = strlen($thisline);
    if( !$tam )
    {
        continue;
    }

    $new_line = ""; 
    for($i=0; $i<$tam; $i++)
    {
        $onechar = $thisline[$i];
        if( $onechar > chr(240) )
        {
            continue;
        }

        if( $onechar >= chr(0x20) )
        {
            $caracteres++;
            $new_line .= $onechar;
        }

        if( $onechar == chr(0x14) )
        {
            $new_line .= "</a>";
        }

        if( $onechar == chr(0x07) )
        {
            $new_line .= "\t";
            if( isset($thisline[$i+1]) )
            {
                if( $thisline[$i+1] == chr(0x07) )
                {
                    $new_line .= "\n";
                }
            }
        }
    }
    //troca por hiperlink
    $new_line = str_replace("HYPERLINK" ,"<a href=",$new_line); 
    $new_line = str_replace("\o" ,">",$new_line); 
    $new_line .= "\n";

    //link de imagens
    $new_line = str_replace("INCLUDEPICTURE" ,"<br><img src=",$new_line); 
    $new_line = str_replace("\*" ,"><br>",$new_line); 
    $new_line = str_replace("MERGEFORMATINET" ,"",$new_line); 


    $outtext .= nl2br($new_line);
}

return $outtext;
} 

$text = parseWord($userDoc);

But now i need to split my string after each space because i want to post each word in my database for a search machine. can somewone help me?

Is there anybody who can help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:36:05+00:00Added an answer on June 16, 2026 at 2:36 am

    If you split on spaces, you’ll get punctuation marks included as part of each word.
    Instead, use str_word_count() with 1 as the second argument.
    This returns a list of all words, without any punctuation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have parsed a file in tcl and i read the line like that
I have parsed XML file into objects, in which each object has a 1:1
I have a CSV file supplied from a client which has to be parsed
I have a simple doc.xml file which contains a single root element with a
I have a class named xmlReader that have parse(String path) and parseXml(Document doc) methods.
I have a file and parts of it looks like this: string 0 1
I have this code List<string> IDs = new List<string>(); XDocument doc = XDocument.Parse(xmlFile); var
I have XML data as a string which has to parsed, I am converting
I have a JSP file inputs a string to a Java class, and should
Hi i have parsed a online xml containing images, I got stuck on parsing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.