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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:49:03+00:00 2026-06-07T14:49:03+00:00

I know helping with homework generally isn’t accepted around here, but I’ve been stuck

  • 0

I know helping with homework generally isn’t accepted around here, but I’ve been stuck for over a week now, so I would be more than grateful for any help. It seems simple in concept, but I can’t get from exploding the file to getting that info into an array.

The goal is to have something to compare the text entered from a form to. For example, if the name Bob is typed into the name field then there would be a way to see if Bob’s name was already on the list.

Here’s my latest attempt:

<?php
    if(isset($_POST['sname'],$_POST['snumber'],$_POST['courseselect']))
    {
        //Has to be submitted first
        $studentname = $_POST['sname'];
        $studentnumber = $_POST['snumber'];
        $course = $_POST['courseselect'];
        if(empty($studentname) || empty($studentnumber))
        {
            //make sure all fields are filled in
            echo "All fields must be filled in";//for if they aren't filled in
        }
        else 
        {
            //if they are filled in
            $studentfile = "students";
            $SF = fopen($studentfile, 'r') or die("$studentfile cannot be opened for reading");

            while($studentlist = fgets($SF))
            {
                list ($stoodname, $stoodnumber) = explode('::', $studentlist);
                $testarray[] = array('$stoodname');
                echo $testarray;
            }
        }
        //end of if/else
    }//end of "has to be submitted"
?>

I feel like I’m just missing something obvious 🙁

  • 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-07T14:49:05+00:00Added an answer on June 7, 2026 at 2:49 pm

    Assuming that your student file is a CSV with :: between the fields:

    <?php
        if(isset($_POST['sname'],$_POST['snumber'],$_POST['courseselect']))
        {
            //Has to be submitted first
            $studentname = $_POST['sname'];
            $studentnumber = $_POST['snumber'];
            $course = $_POST['courseselect'];
            if(empty($studentname) || empty($studentnumber))
            {
                //make sure all fields are filled in
                echo "All fields must be filled in";//for if they aren't filled in
            }
            else 
            {
                //if they are filled in
                $studentfile = "students";
                $SF = fopen($studentfile, 'r') or die("$studentfile cannot be opened for reading");
    
                while($studentlist = fgets($SF))
                {
                    $testArray=explode('::', $studentlist);
                    for($i=0;$<count($testArray);$i++)
                    {
                        if($testArray[$i]==$studentname)
                        {
                            // You found your match!
                        }
                    }
                    print_r($testArray);
                    unset($testArray);
                }
            }
            //end of if/else
        }//end of "has to be submitted"
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this sort of question has been asked here before, but still
I know you guys hate helping with homework, but I thought I might ask
I know you don't like helping others in their homework but I have to
I know this question has been asked few times over SO but none of
Know this might be rather basic, but I been trying to figure out how
soo tired and I know I've seen this before but Google's not helping I'm
I know this is really simple but it just isn't coming to me for
I know that this isn't the first time that this question has been asked,
I know almost no C++ so that's not helping, and my XS isn't much
I know there's similar info on here, but I'm being really dense today and

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.