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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:38:48+00:00 2026-05-23T09:38:48+00:00

Thanks to the many folks who help us out here on Stackoverflow. You all

  • 0

Thanks to the many folks who help us out here on Stackoverflow. You all are awesome! Now to the question. I’ve got an array for the following values: “duck”, “chicken”,”egg”, “pork”, “steak”, “beef”, “fish”, “shrimp”, “deer”, and “lamb.”

I’ve gotten the list to display in Alphabetical order. This is a dynamic array, so it may not always have all these values or be in that order. I’d like to have “Steak” always appear first with “Top Choice” next to it, while keeping the rest in alphabetical order with “Available for Order” next to them.

Here’s what I’ve got thus far with $meat_items as the array:

foreach($meat_items as $meat_item)
     echo $meat_item . ' Available for Order <br>';

I should clarify: Steak may NOT always be a part of the array.

  • 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-23T09:38:49+00:00Added an answer on May 23, 2026 at 9:38 am

    Since you always want steak to appear first, hard code it:

    if (in_array("steak", $meat_items)) {
        `echo "Steak: Top Choice";`
    }
    

    Sort your array alphabetically:

    sort($meat_items);
    

    Then loop through your array, echoing all items except the steak:

    foreach ($meat_items as $meat_item) {
        if ( "steak" != $meat_item ) {
            echo $meat_item . ' Available for Order<br />';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for all your help - see blow original question, and my edit following
edit: many thanks for all the answers. Here are the results after applying the
Hey first question I'm asking here many thanks in advance. I'm using a vector
First of all many thanks for clicking into my question. I have a few
I have got many of my questions solved here, many thanks to you guys.
I've been a fan of EasyMock for many years now, and thanks to SO
many thanks for this site. many posts have helped me recently. this window question
Hello folks! Could you tell me a good(non-redundant) way to find out the following:
Many thanks in advance. I'm working out of a schoolbook and they're using one
Many thanks to marc_s for the following code sample, from my previous issue Creating

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.