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 8812015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:30:20+00:00 2026-06-14T03:30:20+00:00

Possible Duplicate: how to extract data from csv file in php An assignment I

  • 0

Possible Duplicate:
how to extract data from csv file in php

An assignment I have recently received asks of me to make a mock dating site. A lot of the work is provided, and all that is necessary of me is to write the PHP. The part I am stuck on is regarding looking for ‘matches’ between queried names and names in the .txt file (a database of names already inputted). The text file looks like this:

Jenny,F,28,INTJ,Gentoo,18,30
Michael,M,22,ISTJ,Windows,20,25
...
Name,Gender,Age,Personality,OS,minage,maxage

The page I am working with prompts me for a name (of one of the people in the .txt file), and then finds potential matches. A ‘match’ is any person with all of the following: opposing gender, within their respective age ranges, share at least two letters of personality type (eg. ISTP + ESFP = match), and same favorite operating system. It then displays the matches in HTML, which I’m capable of.

My problem is I’m not entirely sure how to cross-reference the text file. I initially thought I should put each line of the .txt into an array element of a larger array:

<?php
    //Initialize the contents of the url (.php?name=$$$) into a variable $inputname
    $inputname = $_GET["name"];
    //Finds how many lines in the singles.txt file
    $lines = count(file("./singles.txt"));
    //Initialize each line into an array
    $matchespre = file("./singles.txt");
?>

…but I’m not sure how I can search for specific characters (INTJ, M, 30, 40, etc etc).

How do I get my desired result? I’m sorry if it’s difficult to understand what my end goal is, the question itself is very hard to follow (in my opinion). Apparently I lack the reputation to post an image, else I’d screengrab the assignment question itself to post.

edit; I think maybe what I’m looking for is a way to put each line of the .txt into a string (eg. string1 = Jenny,F,28,INTJ,Gentoo,18,30; string2 = Michael,M,22,ISTJ,Windows,20,25, etc), then explode() each string into an array, so I have a bunch of arrays. I can then search each array sequentially for matching gender, age range, etc. I just lack the encyclopedia of functions PHP has to offer to know exactly what to do.

  • 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-14T03:30:23+00:00Added an answer on June 14, 2026 at 3:30 am

    I’d split every line into single bits of arguments:

    $arrDating = array();
    foreach($matchespre as $line) {
        array_push($arrDating, explode(',', $line) );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: how to extract data from csv file in php i'm new on
Possible Duplicate: php regex , extract phone number from text/html I have following requirement.
Possible Duplicate: How to extract a file extension in PHP? I have a variable
Possible Duplicate: Get file name from URI string in C# How to extract file
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: how to extract plain text from ms word document file in pure
Possible Duplicate: How can I extract images from a PDF file? I am able
Possible Duplicate: How to extract a node attribute from XML using PHP's DOM Parser
Possible Duplicate: How to extract a file extension in PHP? I found the following
Possible Duplicate: How to extract a file extension in PHP? How can we get

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.