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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:14:17+00:00 2026-05-12T22:14:17+00:00

[Disclaimer: I am new to PHP, and I am just learning, so please no

  • 0

[Disclaimer: I am new to PHP, and I am just learning, so please no flamers, it really hinders the learning process when one is trying to find solutions or information, thank you, and the code works fine in terms of the crossword puzzle, it’s just really baffling me how one gets a diagonal orientation with the given information, or what I am doing wrong and not seeing?]

Given a switch:

  switch ($dir){
case "E":
  //col from 0 to board width - word width
  //row from 0 to board height
  $newCol = rand(0, $boardData["width"] - 1 - strlen($theWord)); 
  $newRow = rand(0, $boardData["height"]-1);

  for ($i = 0; $i < strlen($theWord); $i++){
    //new character same row, initial column + $i
    $boardLetter = $board[$newRow][$newCol + $i];
    $wordLetter = substr($theWord, $i, 1);

    //check for legal values in current space on board
    if (($boardLetter == $wordLetter) ||
        ($boardLetter == ".")){
      $board[$newRow][$newCol + $i] = $wordLetter;
    } else {
      $itWorked = FALSE;
    } // end if
  } // end for loop
  break;

AND:

case "N":
  //col from 0 to board width
  //row from word length to board height
  $newCol = rand(0, $boardData["width"] -1);
  $newRow = rand(strlen($theWord), $boardData["height"]-1);

  for ($i = 0; $i < strlen($theWord); $i++){
    //check for a legal move
    $boardLetter = $board[$newRow - $i][$newCol];
    $wordLetter = substr($theWord, $i, 1);
    if (($boardLetter == $wordLetter) ||
        ($boardLetter == ".")){
      $board[$newRow - $i][$newCol] = $wordLetter;
    } else {
     $itWorked = FALSE;
    } // end if
  } // end for loop
  break;

I should be able to combine the two to get NE (or diagonal text being outputted onto the screen)

HOWEVER, when I try this, it’s not working, and I have been trying different combinations
of N and E to get NE or a diagonal NE orientation with no luck, what gives?

#Tried multiple different combination's of N & E, I am out of ideas 

switch ($dir){
case "E":

  $newCol = rand(0, $boardData["width"] - 1 - strlen($theWord)); 
  $newRow = rand(strlen($theWord), $boardData["height"]-1);


  for ($i = 0; $i < strlen($theWord); $i++){
  #Combined but no luck, WTF:

    $boardLetter = $board[$newRow][$newRow - $i];
     $boardLetter  = $board[$newCol][$newCol + $i];
    $wordLetter = substr($theWord, $i, 1);

    //check for legal values in current space on board
    if (($boardLetter == $wordLetter) ||
        ($boardLetter == ".")){

      $board[$newRow][$newRow - $i] = $wordLetter;
      $board[$newCol][$newCol + $i] = $wordLetter;
    } else {
      $itWorked = FALSE;
    } // end if
  } // end for loop
  break;
  • 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-12T22:14:17+00:00Added an answer on May 12, 2026 at 10:14 pm

    The break; statement will break out of the switch clause after running the code for case "E". You’ll need to set up new, explicit cases for the combinations to make it work that way.

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

Sidebar

Related Questions

Disclaimer: I am fairly new to using json. I am trying to use php
Disclaimer: completely new to Python from a PHP background Ok I'm using Python on
Disclaimer: I'm trying to learn proper OO programming/design, so I'm pretty new to this
Disclaimer: super new to rails. I'm using Rails 3.2 Anyways, I'm trying to create
Disclaimer: Never used php in my life. New to Unix and Jenkins I have
Disclaimer: I'm new to the REST school of thought, and I'm trying to wrap
Disclaimer: I am new to jQuery. I am trying to implement a fadeOut effect
Disclaimer : I am totally new to Ruby on Rails but planning learning it.
Disclaimer: I'm a new convert to iOS, so please feel free to tell me
Disclaimer: I am completely new to PHP and MySQL/SQL. I have multiple implode() functions

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.