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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:36:51+00:00 2026-05-30T10:36:51+00:00

Odd problem here. I’m writing a simple Hangman game in PHP, and while checking

  • 0

Odd problem here. I’m writing a simple Hangman game in PHP, and while checking if the letters in the current word matches those guessed, I run in to a problem.

The code is as follows:


    $letters = str_split($words[$_SESSION['hangman']['current_word']]);
    foreach($letters as $letter)
    {
        if(in_array($letter, $_SESSION['hangman']['guessed']) == True);
        {
            echo "true for ", $letter , "
"; } }

the if-statement will always evaluate to true, even if i change the line to


if(in_array($letter, $_SESSION['hangman']['guessed']) == False);

  • 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-05-30T10:36:53+00:00Added an answer on May 30, 2026 at 10:36 am

    It’s because of the semicolon at the end of your line:

    if(in_array($letter, $_SESSION['hangman']['guessed']) == False);
    

    the semicolon ends the condition; the code after it will always be executed.

    Remove the semicolon to make it work as intended.

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

Sidebar

Related Questions

I found an odd problem when I run a simple csh script on Solaris.
Odd problem, trying to figure out what is going on here with my fresh
I stumbled on a very odd problem while trying to set up a JMenuBar
We have a very odd problem here with SVN. Let me first explain the
Here's an odd problem that's been stumping me for a bit. The program is
I'm facing a bit of an odd problem here. I just launched: http://claudiu.phpfogapp.com/ To
Odd problem here. Working with an existing system that uses TinyMCE as it's text
Here's an odd problem I encountered using Subversion: when merging from a development branch
I had an odd problem, here's the setup: ASP.NET 3.5 app / MSSQLSERVER 2008
I am having a really odd problem trying to set a simple float value

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.