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

  • SEARCH
  • Home
  • 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 6156715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:39:29+00:00 2026-05-23T20:39:29+00:00

I have a huge library file containing a word and it’s synonyms, this is

  • 0

I have a huge library file containing a word and it’s synonyms, this is some words and their synonyms in the format of my library:

aantarrão|1
igrejeiro|igrejeiro|aantarrão|beato

aãsolar|1
desolar|desolar|aãsolar|afligir|arrasar|arruinar|consternar|despovoar|devastar|magoar

aba|11
amparo|amparo|aba|abrigo|achego|acostamento|adminículo|agasalho|ajuda|anteparo|apadrinhamento|apoio|arrimo|asilo|assistência|auxíjlio|auxílio|baluarte|bordão|broquel|coluna|conchego|defesa|égide|encosto|escora|esteio|favor|fulcro|muro|patrocínio|proteção|proteçâo|resguardo|socorro|sustentáculo|tutela|tutoria
apoio|apoio|aba|adesão|adminículo|amparo|aprovação|arrimo|assentimento|base|bordão|coluna|conchego|descanso|eixo|encosto|escora|espeque|fé|fulcro|proteçâo|proteção|refúgio|socorro|sustentáculo
beira|beira|aba|beirada|borda|bordo|cairel|encosta|extremidade|falda|iminência|margem|orla|ourela|proximidade|rai|riba|sopé|vertente
beirada|beirada|aba|beira|encosta|falda|margem|sopé|vertente
encosta|encosta|aba|beira|beirada|clivo|falda|lomba|sopé|subida|vertente
falda|falda|aba|beira|beirada|encosta|fralda|sopé|vertente
fralda|fralda|aba|falda|raiss|raiz|sopé
prestígio|prestígio|aba|auréola|autoridade|domínio|força|halo|importância|influência|preponderância|valia|valimento|valor
proteção|proteção|aba|abrigo|agasalho|ajuda|amparo|apoio|arrimo|asilo|auspiciar|auxílio|bafejo|capa|custódia|defesa|égide|escora|fautoria|favor|fomento|garantia|paládio|patrocínio|pistolão|quartel|refúgio|socorro|tutela|tutoria
sopé|sopé|aba|base|beira|beirada|encosta|falda|fralda|raiz|vertente
vertente|vertente|aba|beira|beirada|declive|encosta|falda|sopé

see aantarrão is a word and below it are the synonyms, I can’t think of a way to get the word and the synonyms on an associative array, this is what I’m trying to do:

<?
$file = file('library.txt');
$array_sinonimos = array();
foreach($file as $k)
{
    $explode = explode($k, "|");
    if(is_int($explode[1]))
    {
        $word = $explode[0];
    } 
}
?>

nothing, lol, what can I do here ? loop lines until I find an empty line then try to get a new word with the explode ?, help !

  • 1 1 Answer
  • 1 View
  • 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-05-23T20:39:30+00:00Added an answer on May 23, 2026 at 8:39 pm

    Here’s some code I cooked up that seems to work.

    See the code in action here: http://codepad.org/TVpYgW91

    See the code here

    UPDATED to read line by line

        <?php 
        $filepointer = fopen("library.txt", "rb");
     $words = array();
    
     while(!feof($filepointer)) {
            $line = trim(fgets($filepointer));
            $content = explode("|", $line);
            if (count($content) == 0)
            continue;
            if (is_numeric(end($content))) {
            $word = reset($content);
            continue;
            }
    
            if (isset($words[$word]))
            $words[$word] = array_merge($words[$word], $content);
            else
            $words[$word] = $content;
        }
    
        print_r($words);
    

    So what’s the strategy?

    1. fix up the line endings
    2. run through the file line by line
    3. ignore empty lines (count($content))
    4. split the line up on the pipes, if the line has a numerical value for the last value, then this becomes our word
    5. we only get to the last step if none of the other traps got touched, because of the continue statements, so if it is then just split up the words by the pipe and add them to or create the array element.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I devlopp web applications with Zend Framework. For now, I have a huge library,
I have a huge XML document 200MB in size containing textual information. The data
I have a huge pl/sql stored procedure, where we make some deletions as long
I have a huge text file and I wanted to write a program which
I have some huge binary driver logs (around 2-5GB each, and probably around 10x
I have a cpp file with a huge class implementation. Now I have to
This question is just to clear some things up. Some things like this have
Suppose I have taken a video file from iphone library. I want to put
I have a huge library in Flash CS5. Sometimes, I need to know in
I have a huge (5,000+ feeds) OPML file which freezes and crashes my browser

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.