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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:59:32+00:00 2026-06-15T01:59:32+00:00

I had to make an array with as indexes A-Z (the alphabet). Each index

  • 0

I had to make an array with as indexes A-Z (the alphabet). Each index had to have a value 0.
So i made this array:

$alfabet = array(
'A' => 0,
'B' => 0,
'C' => 0,
'D' => 0,
'E' => 0,
'F' => 0,
'G' => 0,
'H' => 0,
'I' => 0,
'J' => 0,
'K' => 0,
'L' => 0,
'M' => 0,
'N' => 0,
'O' => 0,
'P' => 0,
'Q' => 0,
'R' => 0,
'S' => 0,
'T' => 0,
'U' => 0,
'V' => 0,
'W' => 0,
'X' => 0,
'Y' => 0,
'Z' => 0
);

I also have got text from a file ($text = file_get_contents(‘tekst15.txt’);)
I have putted the chars in that file to an array: $textChars = str_split ($text);
and sorted it from A-Z: sort($textChars);

What i want is that (with a for loop) when he finds an A in the textChars array, the value of the other array with index A, goes up by one (so like: $alfabet[A]++;

Can anyone help me with this loop? I have this atm:

for($i = 0; $i <= count($textChars); $i++){

while($textChars[$i] == $alfabet[A]){
$alfabet[A]++;
}


}
echo $alfabet[A];

Problem 1: i want to loop the alfabet array to, so now i only check for A but i want to check all indexes.
Problem2: this now returns 7 for each alphabet index i try so its totally wrong 🙂

I’m sorry about my english but thanks for your time.

  • 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-15T01:59:33+00:00Added an answer on June 15, 2026 at 1:59 am

    Heard of the foreach loop?

    foreach ($textChars as $index => $value) {
        $alfabet[$value]++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have had many attempts now on attempting to make this work and i
I have had to make changes to a trigger and assumed that running an
I've had trouble writing this code. I'm supposed to make a function that can
Just wondering if you had any thoughts on this problem. I want to make
I wanted to make an associative array in Javascript in which I would have
I have an array with types and numbers and when printing this is the
i had try to make a split with jQuery on a array field but
I have an array $templates that looks like this: Array ( [0] => Array
Lets say i have this array of movie directors: var directors = ['Woody Allen',
I have no idea how to approach this, and I was hoping someone had

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.