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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:48:54+00:00 2026-06-14T06:48:54+00:00

To check how often an equal value is in my array I count them

  • 0

To check how often an equal value is in my array I count them with:

$count = array_count_values($array_names);

To get each key/value pair I use this foreach loop:

foreach ($count as $key => $value) {
    echo $value . '–' . $key . '<br />'; 
}

Possible output:

2 – Harry Peters
1 – Winston Meyers
3 – Jason Williams

Now I’ve got a second array with URLs:

$urls = array(http://harry-peters.com, http://winston-meyers.com, http://jason-williams.com);

That array should be wrapped around the $key variable like

echo $value . '- <a href="' . $url . '">' . $key . '</a><br />'; 

So I’ll get something like:

2 – <a href="http://harry-peters.com">Harry Peters</a>
1 – <a href="http://winston-meyers.com">Winston Meyers</a>
3 – <a href="http://jason-williams.com">Jason Williams</a>

But I don’t know how to implement another foreach loop for the URLs to the first loop.

  • 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-14T06:48:56+00:00Added an answer on June 14, 2026 at 6:48 am

    Is this useful for you?

    <?php
    
    $names = array
    (
        2 => "Harry Peters",
        1 => "Winston Meyers",
        3 => "Jason Williams"
    );
    
    $urls = array
    (
        "http://harry-peters.com", 
        "http://winston-meyers.com", 
        "http://jason-williams.com"
    );
    
    $counter = 0;
    
    foreach ($names as $key => $value)
    {
        echo $key . '- <a href="' . $urls[$counter] . '">' . $value . '</a><br />';
    
        $counter++;
    }
    

    Be careful because the urls have to be exactly matching the order of the names.

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

Sidebar

Related Questions

I often want to do a quick check of the value of a large
Often I want to check if a provided value matches one in a list
Often I need to check if some value is blank and write that No
I have often the need to check if many values are equal and in
I often use python's assert statement to check user input and fail-fast if we're
I see this often in the build scripts of projects that use autotools (autoconf,
Since people are often using array.length < 1 to check if an array is
My client has a website but doesn't check emails often. He has a lot
Check this code : HTML : <div style="position: absolute; visibility: visible; width: 172px;"> <img
Check this page. On either firefox, chrome, or IE9 / 10 the tabs on

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.